Mysql Multiple table field matching implementation code _MYSQL

Source: Internet
Author: User
Copy Code code as follows:

$sql = $empire->query ("Select Table.title,lianxi,table.dizhi,table.id from Table,table1 where Table1.sid like concat ('%| ', table.id, ' |% ') and table1.id= ". $navinfor [id]." ");
while ($r = $empire->fetch ($sql))
{
$title = $r [' title '];
$lianxi = $r [' Lianxi '];
$dizhi = $r [' Dizhi '];
}

As follows: Two table Info,tag
Info table
ID Name
1 AA and BB
2 BB and CC
3 EE and DD
Tag table
1 AA
2 BB
Name in tag table name match info
There is a problem with this writing:
Copy Code code as follows:

Select Info.id, info.name from Tag,info where info.name like '% ' +tag.name+ '% '

That's right:
Copy Code code as follows:

Select Info.id, info.name from Tag,info where info.name like concat ('% ', tag.name, '% ')
Related Article

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.