Jump to content

Recommended Posts

Posted

Im not sure if i have put this in the right section.....

 

I am wanting to do an query on a database, im using mysql.

 

i want to query 3 fields on a single table but want the results to comeout as just one field. it was a long shot but i tried the following which didnt work, but might explain what i want to do

 

SELECT dt7 AS year7, ict7 AS year7, art AS year7 WHERE sID=1;

 

this didnt work, can anyone shed some light as to how i can do this

 

Thanks

 

Nij

Posted

the data is alphanumeric data...... i want to query 3 fields form the table return the results as if it was 3 entries from a single field in the table...

 

so i would want them returned as year7 and the result would be 3 individual rows from the fields ict7, dt7, art7 etc.....

Posted

it would just make it easier to handle in PHP if i could get it to work like that, as i could just use the array....

 

Im trying to get my script to generate dynamic graphs

Posted

Hows about.....

(SELECT dt7 AS year7 WHERE sID=1)
UNION ALL
(SELECT ict7 AS year7 WHERE sID=1)
UNION ALL
(SELECT art7 AS year7 WHERE sID=1);

 

Should give you one table with one column named year7 containing the data from the 3 SELECT queries.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...