Ask if this statement is feasible!

Source: Internet
Author: User
SELECT * from city WHERE city.pname= $row _a[' pname ')
$row _a[' pname ') is a variable of another table, ask if this sentence is feasible, if it is wrong,


Reply to discussion (solution)

There is no such thing as $row _a[' pname ') in MySQL.

Print out this SQL and put it in the database to see if it can be executed.

Your $row_a[' PName ' is from the PHP program, change to this can be carried out, probably

$sql = "SELECT * from the city WHERE city.pname= ' $row _a[' pname ']"; $result =mysql_query ($sql);


If you simply use MySQL, you need to change $row_a[' pname ' to a specific value, such as
SELECT * from city WHERE city.pname= ' A '

Simple SQL can be executed.

You should be a multi-table cross-query.
Data Sheet Row_a
Data Table City
The field pname in table row_a is equal to the field pname in city

So the statement should be written like this:

Select c.* from city as C inner joins Row_a as R on C.pname=r.pname

You can search the inner join, left JOIN, right join basic know

  • 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.