•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 391,824 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,693 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 422 | Replies: 7
![]() |
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 ....
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.
Aaron Sterling
•
•
Join Date: Dec 2007
Posts: 107
Reputation:
Rep Power: 1
Solved Threads: 13
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: 10
Reputation:
Rep Power: 1
Solved Threads: 1
•
•
•
•
if they are all coming from a single table...call it testTable... then you would just say
SQL Syntax (Toggle Plain Text)
SELECT location1, location2, location3 FROM testTable WHERE ....
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.
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 2:56 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Other Threads in the MySQL Forum
- Previous Thread: urgent reply.. mysql bug... about queries date using MySQL
- Next Thread: please help me with this


Linear Mode