mysql joining query from wordpress db for current user

I have a wordpress db where I am trying to get attendance report based on loged on user id.
Here is the mysql db # Download DB

I have already fetched employee id information and stored it to int_usermeta table inside ‘Zip/Postal Code’ meta value.

Read More

Objective is to run a joining query to show loged in user information.
Here how I was trying …

SELECT MIN(c3) as TimeIn, MAX(c3) as TimeOut, TIMEDIFF (TIME (MAX(C3)), TIME(MIN(C3))) AS working_hours, c2, c4, c5, c7, c8 FROM sec_keico INNER JOIN int_usermeta ON sec_keico.c8 = int_usermeta.meta_value INNER JOIN int_users ON int_users.id = int_usermeta.user_id Where int_usermeta.user_id = '3' Group by C2, C8

Here kindly consider int_usermeta.user_id = ‘3’ where 3 will be replaced by %Current_User_ID%

Is there anything wrong on this query?

I am trying to make a joining query which will first list the data from SEC_KEICO, then read EMP ID from INT_USERMETA (‘Zip/Postal Code’ meta value) and match user id from INT_Users and INT_usermeta by reading %Current_User_ID% and display data only for the current user.

Sorry for my naive questions. But it will be a great help if I could sort it out. Thanks.

Related posts