How to query multiple keywords in mysql

Source: Internet
Author: User
PHPcode $ list = & quot; $ car = array ('name' = & gt; array (0 = & gt; array ('xm '= & gt;' I am special '), 1 = & gt; array ('xm' = & gt; ''), 2 = & gt; array (query of multiple mysql keywords
PHP code
  $ List = ""; $ car = array ('name' => array (0 => array ('xm '=>' I am special '), 1 => array ('xm '=> ''), 2 => array ('xm '=> ''), 3 => array ('xm '=> ''); if (! $ Car ['name']) {$ list = 'Nothing ';} else {$ I = 1; foreach ($ car ['name'] as $ nm) {if (strstr ($ list, $ nm ['xm ']) & $ I = 1) {$ list = str_replace ($ nm ['xm'], $ nm ['xm ']. $ I, $ list); $ list. = $ nm ['xm ']. ($ I + 1 ). ','; $ I ++;} else {if (strstr ($ list, $ nm ['xm ']) {$ list. = $ nm ['xm ']. ($ I + 1); $ I ++;} else {$ list. = $ nm ['xm ']. ',';}}}}


SQL code
  $sql="SELECT * FROM table where table.title in ('$list') limit 0,10";

Php output: I'm special. Hello 1, Hello 2, Hello 3
How can I write a mysql Query statement to make $ list take effect? Or other query methods with the same effect?
Thank you for writing as much detail as possible.






------ Solution --------------------
You have
$ SQL = "SELECT * FROM table where table. title in ($ list) limit 0, 10 ";
I want you to post
Echo $ SQL;
Results! Is it that hard to get it?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.