Archive for the ‘select statement’ Category

sql select statement today’s date - 20 days?

February 15, 2010 - 4:12 am 3 Comments

Hi,

I want to use the SELECT statement to get all my records from my table which is 20 days from the current date. I have been trying all ways but can’t get it.. help will be appreciated!

SELECT WEIGHT, TIME, USER_ID
FROM dbo.WeightTable
WHERE (USR_ID = ‘abc’) AND ….(what to put here)

i am using ms sql server management studio express.. 2005 version. thanks!

SELECT WEIGHT, TIME, USER_ID
FROM dbo.WeightTable
WHERE (USR_ID = ‘abc’)
AND time > dateadd(day, -20, getDate())

How can i create a variable in SSIS that capture information from a Select statement?

January 23, 2010 - 9:49 am 1 Comment

I want to be able to use that variable on the same package in an expression to validate and move to the next step.
So 2 questions:
how to i set a variable from a sql statement?
how to i use a variable as an expression in a constraint?
Thanks you for your help

I haven’t worked with SSIS myself, but take a look at this and see if it answers your questions: http://msdn.microsoft.com/en-us/library/ms140216.aspx

loop of select statement in PHP?

December 27, 2009 - 8:44 am 1 Comment

I have a form with multiple select statements ( 10 select statements)

how can i post the selection of each statement ?

EX:
select city :
select school :
select color :
.
.
.
etc
No i mean <select >
i think it’s called drop down menu

select? you mean like select in mysql?..

How do you write a Select statement that returns all rows in a SQL statement?

December 24, 2009 - 9:51 pm 2 Comments

SQL Oracle

About as simple as it gets:

SELECT * FROM someTable;

Note that doing SELECT * is generally considered bad programming practice…most of the time, you really don’t need every single column of the table, so you’re just needlessly using system resources to retrieve stuff you don’t want anyway.

How do I insert multiple rows in MySQL using nested select statements?

November 17, 2009 - 10:29 pm 3 Comments

e.g. insert into lmms.household (id,family_name,location_id,last_update_time,last_update_user_id,creation_time,creation_user_id) values
((select households_id from world.households),(select family_name from world.households),"93469603",(select last_updated from world.households),"1",(select created_date from world.households),"1");
returns an error- "subquery returns more than one row"?
How can this statement be re-written?

select households_id from world.households
select family_name from world.households
select last_updated from world.households

those statements need to be 1 row.
just put a conditional like where whatever = whatever

What is a select case statement in Visual Basic?

November 14, 2009 - 10:48 pm 1 Comment

How is it the same and different as an if/else if statement?

If statements are designed to select one of two branches. While that can be chained to select from more than two branches, it gets complex and hard to read. The select statement chooses from numerous branches.

If calculates the value of a logical expression. This logical expression may be very complex, but will evaluate to true or false.

Select calculates the value of an expression and then compares the result with a set of constants. The matching constant selects the branch to use.

If you have to select one of many branches it’s more efficient to use the select statement. It’s also much easier to read. If you have multiple options it’s better to express that directly rather than chaining if statements.

Writing code that is easy to understand is very important. Everything you can do to make the intention clearer is worthwhile.

The system can often use smarter comparisons rather than something like "is it 1? no. Is it 2? no. Is it 3? no …"

select the correct statement regarding age-related blood disorders:?

November 5, 2009 - 11:12 pm 1 Comment

a. they are usually the result of the red blood cells wearing out
b. increased incidence of leukemia is not usually associated with aging
c. they include anemias and thromboembolytic disorders
d. they are caused by abnormal forms of hemoglobin f.

c. The others are incorrect.

Select whether the following statement is always true, sometimes true, or never true?

October 31, 2009 - 9:17 pm 4 Comments

The hypothesis of a statement is the if part.

A. Always
B. Sometimes
C. Never

B

SOL Statement to select only the last row in a table?

October 17, 2009 - 8:21 am 3 Comments

I am working with a database that has an auto number field. I am making an applicaton to update the table so I have to have a way to get the last primary key number in the table and add 1 to it so that I can imput the correct number into the primay key field. I need to know if there is an SQL statement that will just pull the last row from a table. Right now I have a count that runs threw the entire database till it get to the bottom and stores the last autonumber in count then I add one to that and store my new data. The problem is it is slow and right now I dont want to get ride of the auto number filed but eventually I will. So anyone know a SQL statement that will go to the last recored right away?

I don’t think this can be done in a single statement. It can be done in two statements though:

SELECT MAX(your auto number field)

And then use that value in your second SELECT.

What is the MS SQL query(Select Statement) for the following:?

October 11, 2009 - 10:22 am 2 Comments

List all details for all Items where the difference between the Item Cost and the List Price exceeds $1?

ex. Select * from Items where ItemCost - ListPrice > ‘1′

The example is not incorrect I think…..

Select * from Items where (ItemCost - ListPrice) > 1

You use quotes only for strings.