-3

how can i reject the sql table empty fields and i want to fetch that not null fields in another page

This is my query

SELECT     e.r_id, 
           e.cmpnyname, 
           e.st_name, 
           e.week, 
           e.desig, 
           e.cm_id, 
           e.weekly_reports 
FROM       reports AS e 
INNER JOIN company AS u 
ON         u.cmpnyname = e.cmpnyname 
WHERE      e.weekly_reports IS NOT NULL 
AND        e.cm_id = ".$_GET['id'];

But this query fetches all the fields including null fields

Can anyone help me to find this

M Khalid Junaid
  • 63,861
  • 10
  • 90
  • 118

1 Answers1

1

You can select both Empty and NULL values

SELECT e.r_id,
       e.cmpnyname,
       e.st_name,
       e.week,
       e.desig,
       e.cm_id,
       e.weekly_reports
FROM reports AS e
INNER JOIN company AS u ON u.cmpnyname = e.cmpnyname
WHERE NULLIF(e.weekly_reports, ' ') IS NOT NULL
  AND e.cm_id =".$_GET['id']."

another statement is much cleaner and more readable

WHERE ISNULL(NULLIF(e.weekly_reports, ''));
munsifali
  • 1,732
  • 2
  • 24
  • 43