Page 1 of 1

Joing data from three tables

Posted: Mon Apr 19, 2004 9:32 am
by JayBird
i have three tables

ocda_images_gd
ocda_images_ra
ocda_images_wd


the three tables have EXACTLY the same structure

Code: Select all

Field      Type          Null    Key     Default  Extra           Privileges                     
---------  ------------  ------  ------  -------  --------------  -------------------------------
id         int(3)                PRI     (NULL)   auto_increment  select,insert,update,references
path       varchar(255)  YES             (NULL)                   select,insert,update,references
caption    varchar(255)  YES             (NULL)                   select,insert,update,references
weighting  char(3)       YES             (NULL)                   select,insert,update,references
main_pic   char(1)       YES             (NULL)                   select,insert,update,references
active     char(1)       YES             (NULL)                   select,insert,update,references
I want to select the data from all 3 tables and display the information. The data from the tables is not related in anyway.

What query do i need to use?

Thanks

Mark

Posted: Mon Apr 19, 2004 9:48 am
by JayBird
Im guessing the UNION function would be useful, but is only available from verison 4 and my host is running bersion 3.23.55

Mark

Posted: Mon Apr 19, 2004 9:48 am
by JAM
If MySQL version >= 4.0.0
http://dev.mysql.com/doc/mysql/en/UNION.html

i think this is the easiest way. The other way I can think of is very sloppy (but it works) but would take some writing. Try UNION first, as I think this would suit you the best.