Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-03-2009
Member
 
Join Date: Nov 2008
Posts: 996
Very simple request in MYSQL but getting no output

I have a very simple query to do and yet I can not, I am fine based on a book. I have two tables: "pages" and "users". In the Pages table, the fields author_id corresponds to id in the users table of the author of the page. "name" is the name of the table field that contains the users name.
Here's where I am:

Code:
  SELECT pages.author_id, users.name 
  FROM pages, users 
  WHERE pages.id = { $this->id } AND users.id = pages.author_id
No error from mysql but no return when the ID that I provided is correct. It is surely very simple but I do not understand the whole problem
Reply With Quote
  #2  
Old 27-03-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: Very simple request in MYSQL but getting no output

Use a JOIN instead of a WHERE condition to join your two tables.

There you met WHERE MyTable.id = my_other_table.fk_id
Use rather FROM MyTable INNER JOIN my_other_table ON id = fk_id
Reply With Quote
  #3  
Old 27-03-2009
Member
 
Join Date: May 2008
Posts: 945
Re: Very simple request in MYSQL but getting no output

author_id is zero so it can not work
Reply With Quote
  #4  
Old 27-03-2009
Member
 
Join Date: May 2008
Posts: 685
Re: Very simple request in MYSQL but getting no output

Quote:
Originally Posted by XSI View Post
Use a JOIN instead of a WHERE condition to join your two tables.

There you met WHERE MyTable.id = my_other_table.fk_id
Use rather FROM MyTable INNER JOIN my_other_table ON id = fk_id
Why? Does it improves performance, or is it another reason?
Reply With Quote
  #5  
Old 27-03-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: Very simple request in MYSQL but getting no output

Yes it improves performance as well as readability.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Very simple request in MYSQL but getting no output"
Thread Thread Starter Forum Replies Last Post
Error parsing Request: The request subject name is invalid or too long. 0x80094001 (-2146877439) Dharitree Windows Security 4 11-01-2014 10:14 AM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
"Simple" many to many relationship - MySQL Soft Pack Software Development 6 07-04-2009 10:36 AM
Simple MYSQL Normalization question - input requested ByteCoder Software Development 1 19-02-2009 12:14 PM
Certificate Request Processor - The request contains no cert templ BrianS Windows Server Help 3 10-05-2007 11:12 PM


All times are GMT +5.5. The time now is 05:58 AM.