SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist ckchin's Avatar
    Join Date
    Mar 2002
    Location
    msia
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to I call this Mysql query

    I have two tables, user and data, as follows:

    user has fileds of userid (PK), name, email.
    data has fileds of dataid (PK), userid, info, calling_id

    Now I want a query as follow:

    I want to query from data table based on calling_id, to call the userid (check the userid) and use the userid to call the user table fileds of name and email so that I can use the email to send all information of data table (info field) to the respective email address.

    How do I do this? I don't think that the below query is correct.

    $query = "SELECT data.userid, data.info, user.name, user.email FROM dataid and userid WHERE data.calling_id=calling_id AND user.userid=userid";

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think this is maybe what you are looking for...

    PHP Code:
    $query "SELECT data.userid AS userid, info, name, email 
    FROM data, user WHERE calling_id = 
    $calling_id AND user.userid = data.userid"
    and $calling_id would be the variable you pass your script. you only need to fully qualify the column names if multiple columns have the same name.

  3. #3
    SitePoint Evangelist ckchin's Avatar
    Join Date
    Mar 2002
    Location
    msia
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I will have a try.


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
  •