php - selecting latest row of transaction table if row contains some values in MySql -


these 2 tables, `leadid` primary key.   table1 - (master)         leadid  customer name     101     ramesh kumar     102     rajan kumar     103     rahul kumar  table2 - (transaction)      id  leadid  followed_by     1   101     sakshi     2   101     madhuri     3   101     sakshi     4   102     sakshi     5   102     madhuri     6   103     sakshi     7   103     sakshi  question : need record `table1` , `table2` , in mahuri has  followed latest on leadid. (as below)  `102        rajan kumar     5   102     madhuri`   in case of sakshi should be:  101     ramesh kumar      3     101     sakshi 103     rahul kumar       7     103     sakshi  if same lead id followed others, previous transcation should not included...  e leadid 101 followed madhuri after followed sakshi.   should not displayed when putting query madhuri. 

this query used getting latest value 'madhuri'

select a.*,b.* `master` inner join `transaction` b on a.leadid = b.leadid followed_by = "madhuri" order b.id desc limit 1;  

to use transction use query

select a.*,b.* `master` inner join `transaction` b on a.leadid = b.leadid b.id = 'userid' order b.id desc limit 1;   

change userid according different users..


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -