Loop-php, while using mysql query statement Problems

Source: Internet
Author: User
Can mysql query statements in php be used like this? Can the mysql query statement of {code...} php be used like this?

$query = "SELECT name FROM bank WHERE area LIKE 'aaa'";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)) {    $http = $row['http'];    $task_query = "SELECT * FROM task WHERE link LIKE'%$http%'";    $task_result = mysql_query($task_query) or die(mysql_error());    while($task = mysql_fetch_array($task_result));            echo $task['high'].'
'; }

Reply content:

Can mysql query statements in php be used like this?

$query = "SELECT name FROM bank WHERE area LIKE 'aaa'";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)) {    $http = $row['http'];    $task_query = "SELECT * FROM task WHERE link LIKE'%$http%'";    $task_result = mysql_query($task_query) or die(mysql_error());    while($task = mysql_fetch_array($task_result));            echo $task['high'].'
'; }

SELECT *FROM task    JOIN (SELECT http AS zhttp FROM bank WHERE area LIKE 'aaa') AS Z     ON task.link LIKE CONCAT('%', Z.zhttp, '%')

SELECT * FROM bank LEFT JOIN task ON task.link LIKE concat('%', bank.http, '%') WHERE bank.area = 'aaa'

I think you may needJOIN....

select task.high from task left join bank on task.link like concat('%', bank.http. '%') where bank.area like 'aaa'

You are$task_query = "SELECT * FROM task WHERE link='%$http%'";Here we want to get the effect of fuzzy match. How can we use it?=What about 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.