Hoping for some help with a sql query. I have the following:
$sql = "SELECT * from
(SELECT m1.post_id as ID,post_date,m1.meta_value as project_name, m2.meta_value as access_key, m3.meta_value as seq_number
FROM wpha_posts
join wpha_postmeta m1 on m1.post_id = ID and m1.meta_key = '_field_5'
join wpha_postmeta m2 on m2.post_id = ID and m2.meta_key = '_field_7'
join wpha_postmeta m3 on m3.post_id = ID and m3.meta_key = '_seq_num'
where post_type = 'nf_sub' AND post_author = ".$profile_id." AND wpha_postmeta.seq_number = ".$seqNumber.") as v1";
$results = $wpdb->get_results($sql);
What I am trying to do is show data that is from two sql tables but only show results where the sequence number matches the number I have passed via the url.
$seqNumber = (int)$_GET['id'];
I am failing at matching with the meta value of the _seq_num meta key in the database.
Any help would be much appreciated