Hello, there are tables kvartira, domkat, garage, commercial, zemelnyi, each one needs to be pulled out city = $ city, tried this way, but without result:

"SELECT id, title, mini_img, text, price, adress FROM kvartira JOIN domkat JOIN garage JOIN commercial JOIN zemelnyi ON city = '$cityS' " 
  • Please do not laugh, this is my first such massive request) - bemulima

1 answer 1

Eco you cool 5 tables.

JOIN is not for this, you just need to combine 5 queries, the UNION operator

 (SELECT id, title, mini_img, text, price, adress FROM kvartira WHERE city = '$cityS') UNION (SELECT id, title, mini_img, text, price, adress FROM kvartira WHERE city = '$cityS') UNION (SELECT id, title, mini_img, text, price, adress FROM domkat WHERE city = '$cityS') UNION (SELECT id, title, mini_img, text, price, adress FROM garage WHERE city = '$cityS') UNION (SELECT id, title, mini_img, text, price, adress FROM commercial WHERE city = '$cityS') UNION (SELECT id, title, mini_img, text, price, adress FROM zemelnyi WHERE city = '$cityS') 

By the way, I venture to ask, why do you need 5 identical tables? It can all merge into one and add the type field, where and write kvartira, domkat, garage, commercial, zemelnyi

  • ))) thanks) - bemulima
  • They are all not the same, well, they have similar ones, you will not help me connect your code to yourself, otherwise I connected the error gives - bemulima