Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm new on Python and would need some help for the following :

I'm building a CRM using Tkinter and Mysql database.

My database was quite big so I decided to split it into several tables (to avoid the VARCHAR limitation among other).

So far I have 5 tables named CRM1, CRM2, CRM3, CRM4, CRM5 and each one have a column "id" as primary key.

As I need to be able to search in the whole database I would like to JOIN all those 5 tables in one query but so far I only succeed to joining the first 2. when I add a second JOIN statement the query fails ...

Here is what I have working so far : (searched is an ENTRY box .get)

sql = "SELECT * " 
  "FROM CRM1 " 
  "JOIN CRM2 " 
  "ON CRM1.id = CRM2.id " 
  "WHERE " 
  "contact_last_name_1 LIKE '%" + searched + "%' OR " 
  "project_1_piano_brand LIKE '%" + searched + "%' ORDER BY CRM1.id DESC"

I tried to add another JOIN statement like this :

sql = "SELECT * " 
  "FROM CRM1 " 
  "JOIN CRM2 " 
  "ON CRM1.id = CRM2.id " 
  "JOIN CRM3 " 
  "ON CRM1.id = CRM3.id " 
  "WHERE " 
  "contact_last_name_1 LIKE '%" + searched + "%' OR " 
  "project_1_piano_brand LIKE '%" + searched + "%' OR " 
  "project_2_piano_brand LIKE '%" + searched + "%' ORDER BY CRM1.id DESC"

But the query returns nothing ..

Can somebody tells me what I'm doing wrong ?

Thanks in advance for your help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
315 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...