Archive for the ‘select statement’ Category

Need help on sql select statement?

September 19, 2009 - 3:08 pm 1 Comment

I am writing two queries that select fields from a dataset:
select r.fld1, s.fld2, s.fld3, r.fld4 from file.a r left outer join filex s where r.fld1=s.fld1;
and
select r.fld1, s.fld2, s.fld3, r.fld4 from file.b r left outer join filex s where r.fld1=s.fld1;

Note that the only difference is in the first file name (file.a vs file.b)

I just want to list all the entries from each file; no summarizing

Can I write one statement instead of two?

What you want is called a SQL Union.

See the following tutorial on how to use this operator:
http://www.w3schools.com/sql/sql_union.asp

Why does my SELECT statement in SQL work with digits for a variable but not with a string for same variable?

September 17, 2009 - 2:44 pm 3 Comments

I am trying to write a script that will create an image on which I can superimpose the text of my choice. Once finished, the script will be called up like any normal image in html, except that the SRC will be the PHP file.

Basically, the problem is that line "A" below works for me in my image-making script, but line "B" doesn’t, even though the string variable contains the same information.

LINE A:

$sql = "SELECT * FROM Facts WHERE CrossReference = ‘5′";

LINE B

$sql = "SELECT * FROM Facts WHERE CrossReference = ‘$ID’";

The Value for the $ID variable is 5 when this image-making include is being run, however the script only works when I hard-code the 5, i.e. when I actually write in the digit rather than the variable.

Why would the above select statement work when I write in the digit and not when I use the same value in a string?

THANKS for any ideas.

I would suggest that you make sure $ID is, in fact, storing the integer 5 when you call the sql. There is no reason that code should not work as you’ve written it, so I suspect that somewhere along the line $ID is either not getting set or is being unset somehow. If you add a simple: echo($sql) right after that sql you’ll know for sure.

Select the false statement regarding chloroplasts?

September 17, 2009 - 2:00 pm 3 Comments

1. Photosynthesis occurs in chloroplasts.
2. Chloroplasts are plant organelles.
3. Chloroplasts have multiple membranes and soluble compartments.
4. Chloroplasts contain only membrane-associated proteins.
5. Chloroplasts can convert to other types of plastids under some conditions.

Just adding to the other replies:

1. True
2. True.
3. True

4 is False,
there are also non-membrane or soluble proteins and enzymes in all plant compartments.

5. True
FYI
Photosynthetically active chloroplast in leaves and stems, activated be light, appear green.
Also produce transient starch.

If seed grown in dark or albino mutation, leaf won’t be green.
But still contain the plastid.

In flowers, chloroplast also contain pigments e.g. yellow chromoplasts.

chloroplasts are clear amyloplasts in roots, tubers, seeds in dark can form storage starch.

how to place or pass the selected value from a datgrid to the select statement?

September 15, 2009 - 10:16 am 1 Comment

For instance…
in datagrid we are having check box.. bound to it….
i am goin to display the column name in it…
user can select or check as many columns he want
suppose if user selects three column means … these three column should get placed in the select query..
for instance…
if user select order id,order name from order table means..
what should i get is
str="select orderid,ordername from order"
the column name must be append to str only during run time…
these process are goin to take place in run time… hence table name ,column name will change based on the selection from the user
help me out to overcome the problem…
any tutorial link or code ‘ll help me lot…
urgent .. make it fast..
i’ll be thank ful for you..
thanks in advance……..

I suppose as follows :

Datagrid1
Column1 Column2 Column3 and so on

now user selects Column1 and column3

first store column checked value as follows:

Dim varC1 as String
if not isnull(Me.datagrid1.Column(0) or _
Me.datagrid1.Column(0) <> "" Then
varC1=Trim(varC1) & Me.datagrid1.Column(0).Value & ","
Endif

if not isnull(Me.datagrid1.Column(1) or _
Me.datagrid1.Column(1) <> "" Then
varC1=Trim(varC1) & Me.datagrid1.Column(1).Value & ","
Endif

if not isnull(Me.datagrid1.Column(2) or _
Me.datagrid1.Column(2) <> "" Then
varC1=Trim(varC1) & e.datagrid1.Column(2).Value
Endif

str="SELECT " & varC1 From urTableName

before executing SQL place Stop beneath str and check if it shows correct value.

Sensenbrenner opening statement for ‘From Poznan to Copenhagen’ hearing

September 14, 2009 - 9:12 pm No Comments

Ranking Member Sensenbrenner’s opening statement at the Select Committee on Global Warming’s “From Poznan to Copenhagen” hearing on February 4, 2009.

Duration : 0:5:19

(more…)

20071017 - Rep. Holt speaks on problems w/ FISA RESTORE ACT

September 12, 2009 - 12:16 am No Comments

Representative Rush Holt’s statement on the problems with the FISA “RESTORE Act.” Holt is a member of the House Intelligence Committee and Chairman of the newly-created Select Intelligence Oversight Panel) statement on the house flor

Duration : 0:2:10

(more…)

SQL data problem - putting select statement results into table?

September 11, 2009 - 4:18 am 2 Comments

i have several select statements, each one is linked by the other the only problem is that because they are all linked by another one they cannot execute the formulas properly because they cannot get the values from the previous.

the first select statement is a Formula, like an Excel formula, the job it does is basically to get a price, to make things clearer this is the statement:

SELECT (Listprice*0.55)
NetPrice
FROM Pricer

the results however do not get put in the actual net price column of the table. i’m assuming they are being put in a temporary column or table of the same name. what i need to happen is for the resulting data to go into my table(without just exporting the results preferably). so that i can do the next select statement (with that resulting data included), get the values and repeat until the table is completely finished.

anyway i don’t know how to get the resulting data from the temporary database/table/column, into the existing column i have for my table.

answers appreciated. cheers

Your code is:
SELECT (Listprice*0.55)
NetPrice
FROM Pricer

It should be:
SELECT (Listprice*0.55) AS
NetPrice
FROM Pricer

If I understand you correctly. Without the ‘AS’ it selects it as a new column that is not defined, and not called.

NHTSA Hearing: Agassi Opening

September 9, 2009 - 1:30 am 3 Comments

Shai Agassi’s opening statement during a recent Select Committee on Energy Independence and Global Warming hearing entitled, “$4 Gasoline and Fuel Economy: Auto Industry at a Crossroads”

Duration : 0:4:58

(more…)

MySQL SELECT Statement?

September 9, 2009 - 1:04 am 3 Comments

Is there any way to get MySQL to run a series of Select statements that will yield quantity totals for one attribute based on multiple tuples…?

::example::
Table, Date, Store, Item Qty
Jan 2, 5, B, -4
Jan 3, 5, C, -3
Jan 3, 1, B, -1
Jan 5, 5, B, -3

I have a statement that will gives the total of item B from one store, but can’t figure out a query that will give the total for item B sold by store 5 AND the total items sold by store 1….
Store 5, Item B, Qty -7
Store 1, Item B, Qty -1

Each item will be a select statement which will be in your program.

For each item you would run the select statement into a variable for later use. you then display the variable/value in the screen (Web or other program).

The select statements are 1 for 1 to each value(s) you are looking for.

Are super huge database select statements impractical?

September 7, 2009 - 12:15 am 3 Comments

on my website, i have some tables that I use to show certain information and statistics. some of the select queries i’m wring to get the results in one swoop are HUGE.

For example, I have a a query that selects from two other queries, one of those being a simple join, and the other being 3x left join… all in one query statement!

it’s pretty big. I’m able to get the results I want with it, but is it just really impractical to have a massive query statement?

If the DB is correctly built and maintained it is often preferable to use one big SQL statement instead of many smaller ones, except if you use DB stored procedures…
The advantages of one big statement include lower network and web server load as you only need to send and receive the data that you actually need…

BTW: I can NOT understand why "julien-marcel" thinks
<quote>
Any query that includes "join" (or sort, or multiple tables) means only ONE thing: your database structure is bad.
</quote>
Does he think that the ONLY good DB structure is one huge flat file with ALL related data stored in one record???