|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
MySQL - Selecting all from two tables
Hey guys, I'm trying to do something along these lines, select all the columns from 1 table, inner join an id field on another table and select all the columns from that table aswell, is this possible?
Otherwise I can just run two queries, but Id rather do it in one.
__________________
~~==~~ Whoever said nothing is impossible never tried pushing a revolving door ~~==~~ |
|
#2
|
|||
|
|||
|
Nevermind, got it
Code:
select * from table1, table2 where table1.col1 = table2.col1 |
|
#3
|
||||
|
||||
|
If possible I prefer to use the ANSI JOIN syntax for readability and actually naming all the columns to be returned rather then using * - See http://parseerror.com/sql/select*isevil.html
Code:
SELECT <col_name>
FROM table1
JOIN table2
ON table1.col1 = table2.col1
__________________
life is a game.... Have fun ----------------------------- http://www.phpwomen.org strength in unity PHPCommunity IRC #phpc on freenode |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > MySQL - Selecting all from two tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|