Database mysql-how do I query fields in two tables that have the same part but are not exactly the same?

Source: Internet
Author: User
I have two tables in my hand with place names. now I need to compare the place names of the two tables, see which are the same but not exactly the same (for example, in Table a, Beijing is written in Table B), and in Table a, the pid & gt; 0 and city0 I wrote a statement $ SQL & quot; select * frombyzk_areasaleftjoinbyzk_fuiou_citybona.namelike & #39; B. cname % & #39; wherea. pid & gt; 0anda. city0 & quot; but it seems wrong !!! Great help database mysqlphpsql statements

I have two tables in my hand with place names. now I need to compare the place names of the two tables, see which are the same but not exactly the same (for example, in Table a, Beijing is written in Table B), and in Table a, the pid> 0 and city = 0 must be met.
I wrote a statement myself.
$ SQL = "select * from byzk_areas a left join byzk_fuiou_city B on a. name like 'B. cname %' where a. pid> 0 and a. city = 0 ";
But it seems wrong !!! Thank you!

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.