How does the query in the while loop be simplified?

Source: Internet
Author: User
I'm here to complete the language trouble please MySQL teacher

$gettimeline = mysql_query("SELECT * FROM `timeline`LEFT JOIN `users_profile` USING (id)ORDER BY `addtime_timeline`  DESC");

The above is to find timeline list and arrange it in Addtime_timeline

while ($row=mysql_fetch_array($gettimeline)){ 印出timeline的欄位資料}

The above is the cycle of printing out timeline information

In the loop I'll add the following query

  while ($row =mysql_fetch_array ($gettimeline)) {$GETthumb 1 = mysql_query ( "SELECT * from ' timeline_thumb ' WHERE ' id ' = '". $_session[' userid ']. "' and ' by_timeline_id ' = ' ". $row [' timeline_id ']." ' and ' thumb_type ' = ' 1 '); $pub _getthumb1 = mysql_query ("select * from ' timeline_thumb ' WHERE ' by_timeline_id ' = '". $row [' Ti meline_id ']. "' and ' thumb_type ' = ' 1 ' "); $pub _getinfo = mysql_query (" select * from ' timeline_thumb ' JOIN ' Users_profile ' USING (ID) WHERE ' by_timeline_id ' = ' ". $row [' timeline_id ']." ' ORDER by ' addtime_thumb ' DESC); $get _comment = mysql_query ("select * from ' timeline_comment ' JOIN ' users_profile ' USING (i d) WHERE ' re_timeline_id ' = ' ". $row [' timeline_id ']." ' ORDER by ' addtime_comment ' DESC); $get _comment_num = mysql_query ("select * from ' timeline_comment ' WHERE ' re_timeline_id ' = '. $row [' timeline_id ']. "'");}  

GETTHUMB1 is a few strokes of the ID (by_timeline_id) that matches the timeline (timeline_id) in the Timeline_thumb information table (a few strokes of the user's own pen).
The PUB_GETTHUMB1 is a total of a few pens.
Pub_getinfo is to capture the user's information and users_profile (ID) response.
Get_comment is the ID (re_timeline_id) that catches the timeline (timeline_id) in the Timeline_comment information table and grabs the user's information and users_profile (ID).
Get_comment_num is grasping out a total of a few pens.

Is there a space for you to simplify MySQL? ........

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