user2704822
user2704822

Reputation: 29

PHP MYSQL Returning Result Two Times (Double)

SQL Quires is displaying multiple values

i mean if sql query actually out put is like this :

10456123   4561265    12   13   45  55   66
45869655   4556446    99   56   45  45   45

it is displaying as :

10456123   4561265    12   13   45  55   66
45869655   4556446    99   56   45  45   45
10456123   4561265    12   13   45  55   66
45869655   4556446    99   56   45  45   45

It is Showing DOUBLE times (2times)

Upvotes: 0

Views: 1405

Answers (2)

DARK_A
DARK_A

Reputation: 575

Try adding DISTINCT:

SELECT DISTINCT * 
  FROM 32r07,
       32r07names 
 WHERE 32r07.htno = 32r07names.htnon 
   AND 32r07.htno = '$name'

SELECT DISTINCT * 
  FROM 32r07names 
 WHERE htnon = '$name'

This is not plroblem solver, but it will help. also, DO NOT use *. I think you need to check for duplicate values in tables.

Upvotes: 1

erKURITA
erKURITA

Reputation: 407

You are actually executing (almost) the same query twice:

SELECT * FROM 32r07, 32r07names WHERE 32r07.htno = 32r07names.htnon AND 32r07.htno = '$name';

could be rewritten as

SELECT * FROM 32r07 INNER JOIN 32r07names ON htno = htnon WHERE 32r07.htno = '$name';

The second query being

SELECT * FROM 32r07names WHERE htnon = '$name';

Which is like saying, altogether:

... WHERE htnon = htno = '$name';

Upvotes: 0

Related Questions