Matching data from 2 table with validation date |
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.
@
You need to determine what join you want (https://www.cloudways.com/blog/wp-conten...ysql-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'
(02-06-2019, 07:45 PM)php_rocs Wrote: @ 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?
@
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
(02-07-2019, 04:35 PM)php_rocs Wrote: @ 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()
@
I prefer to use the query bindings feature ( https://www.codeigniter.com/userguide3/d...y-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
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.
(02-08-2019, 09:19 AM)php_rocs Wrote: @ 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() |
Welcome Guest, Not a member yet? Register Sign In |