Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Search Today's Posts Mark Forums Read

Go Back   EduGeek.net Forums > Coding and Web Development > Coding
Reply
 
LinkBack Thread Tools Search Thread Language
Sponsored Links
Old 05-10-2006, 11:16 AM   #1
 
Nij.UK's Avatar
 
Join Date: May 2006
Location: Leicestershire
Posts: 346
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 Nij.UK is an unknown quantity at this point
Send a message via MSN to Nij.UK
Default SQL Question

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

Code:
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
  Reply With Quote
Old 05-10-2006, 11:38 AM   #2
 
Geoff's Avatar
 
Join Date: Jun 2005
Location: Fylde, Lancs, UK.
Posts: 9,931
uk uk lancashire
Thanks: 42
Thanked 230 Times in 209 Posts
Blog Entries: 1
Rep Power: 67 Geoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud of
Send a message via ICQ to Geoff Send a message via AIM to Geoff Send a message via MSN to Geoff Send a message via Yahoo to Geoff Send a message via Skype™ to Geoff
Default Re: SQL Question

What is the data? numbers? do you want to add them up?
  Reply With Quote
Old 05-10-2006, 11:46 AM   #3
 
Nij.UK's Avatar
 
Join Date: May 2006
Location: Leicestershire
Posts: 346
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 Nij.UK is an unknown quantity at this point
Send a message via MSN to Nij.UK
Default Re: SQL Question

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.....
  Reply With Quote
Old 05-10-2006, 11:50 AM   #4
 
Geoff's Avatar
 
Join Date: Jun 2005
Location: Fylde, Lancs, UK.
Posts: 9,931
uk uk lancashire
Thanks: 42
Thanked 230 Times in 209 Posts
Blog Entries: 1
Rep Power: 67 Geoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud of
Send a message via ICQ to Geoff Send a message via AIM to Geoff Send a message via MSN to Geoff Send a message via Yahoo to Geoff Send a message via Skype™ to Geoff
Default Re: SQL Question

Code:
SELECT dt7 + ict7 + art AS year7 WHERE sID=1;
  Reply With Quote
Old 05-10-2006, 11:54 AM   #5
 
Nij.UK's Avatar
 
Join Date: May 2006
Location: Leicestershire
Posts: 346
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 Nij.UK is an unknown quantity at this point
Send a message via MSN to Nij.UK
Default Re: SQL Question

that adds the values together..... i want the results from each field as 3 individual results. individual rows
  Reply With Quote
Old 05-10-2006, 11:57 AM   #6
 
Geoff's Avatar
 
Join Date: Jun 2005
Location: Fylde, Lancs, UK.
Posts: 9,931
uk uk lancashire
Thanks: 42
Thanked 230 Times in 209 Posts
Blog Entries: 1
Rep Power: 67 Geoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud of
Send a message via ICQ to Geoff Send a message via AIM to Geoff Send a message via MSN to Geoff Send a message via Yahoo to Geoff Send a message via Skype™ to Geoff
Default Re: SQL Question

Then do 3 selects?
  Reply With Quote
Old 05-10-2006, 01:36 PM   #7
 
Nij.UK's Avatar
 
Join Date: May 2006
Location: Leicestershire
Posts: 346
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 Nij.UK is an unknown quantity at this point
Send a message via MSN to Nij.UK
Default Re: SQL Question

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
  Reply With Quote
Old 05-10-2006, 01:54 PM   #8
 
Iain's Avatar
 
Join Date: Oct 2006
Location: Warwickshire
Posts: 91
uk
Thanks: 1
Thanked 17 Times in 12 Posts
Rep Power: 7 Iain will become famous soon enough
Default Re: SQL Question

Hows about.....
Code:
(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.
  Reply With Quote
Old 05-10-2006, 01:57 PM   #9
 
Nij.UK's Avatar
 
Join Date: May 2006
Location: Leicestershire
Posts: 346
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 Nij.UK is an unknown quantity at this point
Send a message via MSN to Nij.UK
Default Re: SQL Question

thanks Iain.... i think u just hit the nail on the head, just what i was looking for and works aswell!

Cheers mate!
  Reply With Quote
Reply

Register now for FREE and post messages!


Username: Password: Confirm Password: E-Mail: Confirm E-Mail:
Birthday:      
Image Verification
  I agree to forum rules 

Similar Threads
Thread Thread Starter Forum Replies Last Post
Here's a question for you! azrael78 Hardware 15 01-10-2007 10:33 AM
Win 2k PDC question glennw Windows 2 27-09-2007 12:17 PM
dvd question strawberry Hardware 3 24-08-2007 04:17 PM
Question Elky Recommended Suppliers 48 07-11-2006 02:02 PM



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search Thread
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +1. The time now is 08:18 PM.
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright EduGeek.net