sql - Query a list of names from one table that appear in a field in a different table -
I ask a list of names from a table that will appear in a field in a separate table.
example:
table1.title> Tiger Woods Cheats, Tiger Woods Crash, Brad Pitt is Great, Madonna Adoption, Brad Pitt Makes a Movie
Table2. Name> Tiger Woods, Brad Pitt, Madonna
So these are two tables and values. I would like to write a query that calculates which name of table 2 names table 1 The most visible in Tetal is
Someone has suggested using it internally, but I could not work it ... I appreciate the help !! Thank you.
Use:
SELECT a.names, COUNT (b . Title) Add a tab to the table number JOIN TABLE_1 b ON INSTR (b.title, a.names) & gt; View documentation about 0 by a.names ORDER by number DESC
- Checking the value of more than 0, this means that the title is in the title, otherwise it will be zero .
AS number
is a column nickname, which you can refer to in ORDER BY
or to sort in the ASCending or DESCending command.
Comments
Post a Comment