创建引用元值的sql查询

p8ekf7hl  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(253)

希望能对sql查询有所帮助。我有以下几点:

$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);

我要做的是显示来自两个sql表的数据,但只显示序列号与我通过url传递的数字匹配的结果。

$seqNumber = (int)$_GET['id'];

我无法匹配数据库中_seq_num meta键的meta值。
任何帮助都将不胜感激

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题