简体   繁体   中英

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)

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.

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';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM