Jump to content

Selecting 2 tables from 1 query


Mutley

Recommended Posts

ok but i think it goes like:

 

 

SELECT table_a.column_name, table_b.column_name, table_b.clolumn_name FROM table_a, table_b WHERE ID = 'VALUE'

 

it will change for your database.... and you have to have a pre set up relationship between the two tables....... i can look it up if you want, but someone probably knows off by heart

 

 

good luck

How should the tables be joined? which column in first table matches which column in second table?

 

try

<?php
$sql = "SELECT a.field_1, b.field_2, b.field_3
        FROM table_a a INNER JOIN table_b b ON a. field_x = b.field_y
        WHERE a.field_p = 'something'
        AND b.field_q = 'somethingelse'";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.