simple sql help

Discussion in 'MySQL' started by Gnome, Feb 2, 2008.

  1. #1
    Hi,

    I have a table in a database which has 2 fields, userid and impressions

    what I want to do is specify the userid and read the impressions for that userid

    what query would i use? thanks
     
    Gnome, Feb 2, 2008 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #2
    SELECT impressions FROM table_name WHERE userid = insert ID here;
     
    SoKickIt, Feb 2, 2008 IP
  3. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    select * from yourtable where userid='someid';
    
    Code (markup):
    That is the mysql query. If you are looking to display it using PHP then do:

    
    <?php
    $userid='someid';
    $q="select * from yourtable where userid='$userid'";
    $r=mysql_query($q);
    while ($row = mysql_fetch_array($r)){
            $userid=$row['userid'];
            $impressions=$row['impressions'];
            echo "Userid: $userid\n";
            echo "Impressions: $impressions";
    }
    ?>
    
    PHP:
     
    LittleJonSupportSite, Feb 2, 2008 IP
  4. Gnome

    Gnome Active Member

    Messages:
    236
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    thank you soo much!
     
    Gnome, Feb 2, 2008 IP