Re: [PHP-DB] Is this syntax is correct?

[email protected] (Ken Kixmoeller)
Newsgroups php.db
Message-ID <[email protected]>
Amit Tandon wrote:
> SELECT d.username,  r.password FROM data join  registration r on r.username

>> SELECT username FROM data, password FROM registration WHERE username=%s AND
>> password=%s"

Oh, boy -- "r on r"?? Obviously the guy is a rookie.
Let's be simple:

SELECT data.username,registration.password
  FROM data inner join registration
   ON data.<linking_field> = registration.<linking_field>
  WHERE username=%s
   AND password=%s"

<linking_field> is the name of the common field in each table, such as 
"user_id".

Comments:

1. "data" is a really bad name for a table. You will confuse the heck 
out of yourself and others who follow you. Change it.

2. As Amit kind of said, no password should be stored in a table 
(available on a web server) without encrypting the password information.

Ken
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.