Flag MySQL table records based on a second table -


i have 2 tables: table has list of records.

recordid  datetime              clientid 1         2017-07-01 17:20:21   1 2         2017-07-01 17:01:41   2 3         2017-07-01 17:20:30   1 4         2017-07-01 17:10:23   2 5         2017-07-01 17:01:20   2 6         2017-07-01 17:15:11   2 .... 

table b holds number of valid records client.

clientid  date          validrecords 1         2017-07-01    1 2         2017-07-01    2 

i need query takes number (n) table b , flag (1 or 0) amount (n) of records in table a.

the expected result:

recordid  datetime              clientid    valid 1         2017-07-01 17:20:21   1           1 2         2017-07-01 17:01:41   2           1 3         2017-07-01 17:20:30   1           0 4         2017-07-01 17:10:23   2           1 5         2017-07-01 17:01:20   2           0 6         2017-07-01 17:15:11   2           0 

client 1 has 1 correct record, other 1 0. client 2 has 2 correct records, others should marked 0.

any ideas welcome.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -