SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Combining queries...

    Code:
    mysql_select_db("bucktown");
    safe_query("SELECT * from tips where verify=1 and zone='".$zone."' order by date desc");
    
    safe_query("SELECT DATE_FORMAT(date, '%m/%d/%Y') as date from tips where tip_id='".$row["tip_id"]."'");
    
    mysql_select_db("main");
    safe_query("SELECT username FROM user WHERE userid='".$row["userid"]."'");
    I have 3 queries that I want to combine to 1 if possible, the first 2 are on the same database, the other one is from my vB database, which I am using for user authentication.

    What I am really curious about is the first 2. I can't figure out how to format the date how I want it in the first query, it gets the date, but then I ask for it again, so that I can get it in the right format. Can I do this?

    Code:
    safe_query("SELECT * from tips where verify=1 and zone='".$zone."' DATE_FORMAT(date, '%m/%d/%Y') order by date desc");


  2. #2
    You want what? By when?? Milamber's Avatar
    Join Date
    Jan 2001
    Location
    California
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    safe_query("SELECT * from tips where verify=1 and zone='".$zone."' order by date desc");

    safe_query("SELECT DATE_FORMAT(date, '%m/%d/%Y') as date from tips where tip_id='".$row["tip_id"]."'"); 

    to --->


    PHP Code:
    safe_query("SELECT insert_actual_field_names_from_tips_table_here, DATE_FORMAT(date, '%m/%d/%Y') as date  FROM tips WHERE verify=1 and zone='$zone' ORDER BY date DESC"); 
    you need to actually instead of just saying * for all fields, specify the fields....that's how i'd do it anyhow.
    -Jeff Minard | jrm.cc - Battlefield 2 Stats

  3. #3
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    COOL! Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •