logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-03-2011, 02:04 AM   #1
NerdArmy
 
Join Date: Nov 2011
Location: Chicago
Posts: 9
Default Searching multiple mysql tables, JOINS?

I'm creating a mysql keyword search on my website and I know how to search a single mysql table, my problem is I need to search 15 different tables simultaneously, they also all have the same column names. I was told I have to you JOINS but i've never used them before. How is this done?



MY SQL SELECT:


SELECT *
FROM mytable1

WHERE keyword LIKE %colname% OR id LIKE %colname%
NerdArmy is offline   Reply With Quote
Old 12-03-2011, 02:24 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

"SELECT * FROM table1 JOIN table2 ON table1.title=table2.title where......"

this will join table1 to table2 where title on 1 and 2 are equal
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-09-2011, 02:54 PM   #3
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

I would create a VIEW in MYSQL with your joins defined. It will be a lot quicker.

A view behaves like a virtual table which already has the joins indexed so you just need to run a simple SELECT on the view
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:02 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com