Skip navigation
Currently Being Moderated

selecting data from two tables

Jun 15, 2012 5:25 PM

Tags: #php #database #query #sql

I am trying to select data from two tables.  The only problem that I am running into, is that i am only seeing results from my 'uploads' table.  there is also a record in documents where user = 1 that should show up.  here is my sql:

 

$userIDNum = 1;

$sql="Select *

from uploads, documents

WHERE uploads.user = documents.user AND uploads.user = $userIDNum

ORDER BY uploads.title ASC, documents.title ASC";

 
Replies
  • Currently Being Moderated
    Jun 18, 2012 10:10 AM   in reply to future-architect

    You'll need to explain a little more about your data and what you are trying to accomplish. Your current sql will select all columns from both the uploads and documents tables but only rows where the user id in both tables match, AND the user id equals 1. Is that not what you are seeing? Where's the code that outputs the results?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points