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

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

iphone - How do I make a UIPickerView in a UIActionSheet -