-1

I use this query to get an Ads Info by title. My SQL Code:

This SQL Code work but it search only for title.

select a.title, b.type from ads a
inner join ads_infos b on a.title like concat('%', b.type, '%')
where a.id='1'

I want to use Inner Join with Concat for title and description.

select a.title, b.type from ads a
inner join ads_infos b on a.title like concat('%', b.type, '%')
inner join ads_infos b on a.description like concat('%', b.type, '%')
where a.id='1'

but this doesnt work.

SQL FIDDLE: Link

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    So you have repeated the question and used an answer from someone who helped you in your new question? https://stackoverflow.com/questions/58671327/matching-records-from-two-tables – VBoka Nov 02 '19 at 18:07
  • try to use a different alias for the second join of `ads_infos` – Barbaros Özhan Nov 02 '19 at 18:07

1 Answers1

-2

In this case if you need two conditions on the same table, you should use AND if you need both

select a.title
, b.type 
from ads a
inner join ads_infos b on a.title like concat('%', b.type, '%')
   AND a.description like concat('%', b.type, '%')
 where a.id='1'

or

OR if you need one of the two

select a.title
, b.type 
from ads a
inner join ads_infos b on a.title like concat('%', b.type, '%')
  OR a.description like concat('%', b.type, '%')
 where a.id='1'
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107