Nij.UK Posted October 5, 2006 Posted October 5, 2006 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
Geoff Posted October 5, 2006 Posted October 5, 2006 What is the data? numbers? do you want to add them up?
Nij.UK Posted October 5, 2006 Author Posted October 5, 2006 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.....
Nij.UK Posted October 5, 2006 Author Posted October 5, 2006 that adds the values together..... i want the results from each field as 3 individual results. individual rows
Nij.UK Posted October 5, 2006 Author Posted October 5, 2006 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
Iain Posted October 5, 2006 Posted October 5, 2006 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.
Nij.UK Posted October 5, 2006 Author Posted October 5, 2006 thanks Iain.... i think u just hit the nail on the head, just what i was looking for and works aswell! Cheers mate!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now