Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Searching multiple mysql tables, Joins?

Guest
Dec 02, 2011 Dec 02, 2011

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%


TOPICS
Server side applications
734
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 02, 2011 Dec 02, 2011

You join tables when you want to view related data. Let's start at the beginning. Why do you have 15 tables with the same column names?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 02, 2011 Dec 02, 2011

I have an image based site, and the images are separated into 15 different catigories depending on what type of image it is. The columns are id,image,name,keyword for each table

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 02, 2011 Dec 02, 2011

Why not just put all into a single table? What is the purpose for separating these into 15 tables?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 02, 2011 Dec 02, 2011

Because for the type of site im doing the images must remain in there specific category, and can't be mixed into one table.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 02, 2011 Dec 02, 2011
LATEST

OK, that really doesn't answer my question. Just because they are in different categories is not a valid reason. Why can't they be mixed?

In any case, you could probably use a UNION query to solve the current problem, but I would have to know more about the complete query. You don't want to use a JOIN.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines