Is it possible to filter certain null values after left join using some conditions in mysql
my sqlfiddle for reference
http://sqlfiddle.com/#!2/cb03b/1
i want to return the tables with their status for a particular booked datetime i have added the date condition but its returning rows of booking of other dates with the status
is my table structure is wrong or is their a solution for it….
expected output for date December, 09 2012 00:00:00+0000
TABLE_ID FLOOR_ID TABLE_STATUS BOOKING_ID D
1 1 seated 35 December, 09 2012 00:00:00+0000
2 1 free (null) (null)
3 1 free (null) (null)
4 1 free (null) (null)
5 1 free (null) (null)
but i am getting other nulls from booking table
TABLE_ID FLOOR_ID TABLE_STATUS BOOKING_ID D
1 1 seated 35 December, 09 2012 00:00:00+0000
2 1 (null) (null)
2 1 (null) (null)
3 1 free (null) (null)
4 1 free (null) (null)
5 1 free (null) (null)
You can use
Group Byto do this, but it isn’t really clear what you want in the case of multiple matches for one table. You can use a combination ofleft outer joinandinner jointo ignore the unwanted booking_table rows:You could use a
right outer jointo avoid the nesting, but it’s not generally recommended:http://sqlfiddle.com/#!2/cb03b/20