Matching data from 2 table with validation date - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Matching data from 2 table with validation date (/showthread.php?tid=72748) |
Matching data from 2 table with validation date - DELE - 02-06-2019 At this time I have data from the database, results of the join data table users and table campaigns, like this : ID 001 005 008 and I have data from table incomes, like this : id name date 1 001 2018-10-10 2 005 2018-10-10 3 008 2018-10-10 4 001 2018-10-11 how to check the results of the join data in table incomes? if the data ID is not the same as the data name on 2018-10-11, the results will be obtained : ID 005 008 The question: what query should I use and what method do I need to apply in the controller / view. if the masters here are willing to include with simple code it is very very valuable to me. thank you, greetings coding. RE: Matching data from 2 table with validation date - php_rocs - 02-06-2019 @DELE, You need to determine what join you want (https://www.cloudways.com/blog/wp-content/uploads/mysql-1.png ) This might work for you... select ucj.id from users_campaigns_join ucj inner join incomes i on i.id = ucj.id where i.date = '2018-10-10' RE: Matching data from 2 table with validation date - DELE - 02-07-2019 (02-06-2019, 07:45 PM)php_rocs Wrote: @DELE, from users_campaigns_join ucj // this is not a table but results from a combination of user tables and campaign tables, are you sure this way? RE: Matching data from 2 table with validation date - php_rocs - 02-07-2019 @DELE, users_campaigns_join could be a view or a query (subset of data). I just used the name to represent the data. Like below... PHP Code: select ucj.id RE: Matching data from 2 table with validation date - DELE - 02-08-2019 (02-07-2019, 04:35 PM)php_rocs Wrote: @DELE, I do not really understand your point. this is the code that I use to produce (what you call) ucj. PHP Code: public function test1() how to implement your method using this method? PHP Code: public function test2() RE: Matching data from 2 table with validation date - php_rocs - 02-08-2019 @DELE, I prefer to use the query bindings feature ( https://www.codeigniter.com/userguide3/database/queries.html#query-bindings ). This gives me more flexibility to write my own queries and the binding feature automatically escapes the variables for me. So my code would look like... PHP Code: $sql = "select ucj.id RE: Matching data from 2 table with validation date - DELE - 02-08-2019 I understand the meaning of the flow of your code, which I am confused is the users_campaigns_join_view. because what I know is that it must contain the name of the database table that will be joined. RE: Matching data from 2 table with validation date - php_rocs - 02-08-2019 @DELE, Are you familiar with views? Not CI views but database views? RE: Matching data from 2 table with validation date - DELE - 02-09-2019 (02-08-2019, 09:19 AM)php_rocs Wrote: @DELE, thank you very much for your help, my knowledge in the database is still ordinary. but now I have got what I want. I look for differences between two tables. thank you again for your help. PHP Code: public function test() |