| | |
Can i retrive different fields of a record as one result.
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Dear All,
I am new to MySQL. Can i retrive the result of a query as the combination of different fields of a single record..
For example..
if the result record of a query is ... id(1), country(India), Location1(maharashtra), Location2(pune), Location3(Navi Mumbai)...
My doubt is that can i retrive the 3 locations as one field..
Please excuse me if this is a foolish question..
Regards,
Jino..
I am new to MySQL. Can i retrive the result of a query as the combination of different fields of a single record..
For example..
if the result record of a query is ... id(1), country(India), Location1(maharashtra), Location2(pune), Location3(Navi Mumbai)...
My doubt is that can i retrive the 3 locations as one field..
Please excuse me if this is a foolish question..
Regards,
Jino..
We only have to do a very few things right in our life, so long as we don't do too many things wrong.
if they are all coming from a single table...call it testTable... then you would just say
and then you can fill in whatever goes in the WHERE clause to get the result you want. In general you can list as many fields as you want plus other goodies in the select expression (the part where you tell it what you want) of a SELECT statement. They have to seperated by commas.
SQL Syntax (Toggle Plain Text)
SELECT location1, location2, location3 FROM testTable WHERE ....
Aaron Sterling
•
•
Join Date: Dec 2007
Posts: 195
Reputation:
Solved Threads: 27
You can use CONCAT()/CONCAT_WS() functions to get as many fields as you want as a single column.
sql Syntax (Toggle Plain Text)
SELECT id, CONCAT(', ', location1, location2, location3) FROM table
•
•
Join Date: Apr 2008
Posts: 17
Reputation:
Solved Threads: 1
•
•
•
•
if they are all coming from a single table...call it testTable... then you would just say
and then you can fill in whatever goes in the WHERE clause to get the result you want. In general you can list as many fields as you want plus other goodies in the select expression (the part where you tell it what you want) of a SELECT statement. They have to seperated by commas.SQL Syntax (Toggle Plain Text)
SELECT location1, location2, location3 FROM testTable WHERE ....
that's exactly what i've been using
SQL Syntax (Toggle Plain Text)
SELECT location1 a, location2 b , location3 c FROM testTable WHERE a.someField = b.someOtherField AND b.someOtherField = c.someOtherFieldToo
OR LIKE THIS :
SQL Syntax (Toggle Plain Text)
SELECT location1 a LEFT JOIN location2 b ON a.someField = b.someOtherField WHERE someOtherField = 'blabla'
Last edited by swingingstars; Apr 18th, 2008 at 3:56 am.
![]() |
Other Threads in the MySQL Forum
- Previous Thread: urgent reply.. mysql bug... about queries date using MySQL
- Next Thread: please help me with this
Views: 876 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for MySQL
"use" 1 agplv3 alfresco amazon api artisticlicense aws bizspark camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright court crm data database design developer development distinct dui ec2 eliminate enter enterprise error facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword kickfire laptop legal license licensing linux maintenance mariadb matchingcolumns metron microsoft microsoftexchange mindtouch mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource operand oracle penelope php priceupdating query referencedesign remove reorderingcolumns saas search select sharepoint simpledb spotify statement sugarcrm syntax techsupport thunderbird update virtualization





