본문 바로가기
MySql

MySQL 워드 프레스에서 쿼리 선택

by 베이스 공부 2020. 12. 20.
반응형

나는 이것을 2 시간까지하려고한다. I have custom fields in database and I want to get post_id by the meta keys or meta values. 나는 이렇게하고있다

$post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE (meta_key = 'mfn-post-link1' AND meta_value = '". $from ."')");
print_r($post_id); // giving only 140

이것은 잘 작동하지만 이것은 하나의 post_id 만 제공하고 가능한 모든 post_id를 meta_value와 일치시키고 싶습니다. for example : I have three post 140,141,142, in database. But by this query I am only getting 140. 이 쿼리 또는 meta_fields를 비교하여 다른 방법으로 가능한 모든 post_id를 얻는 방법에 대한 아이디어 ...

감사

 

해결 방법

 

$post_id = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE (meta_key = 'mfn-post-link1' AND meta_value = '". $from ."')");
print_r($post_id); /

 

참조 페이지 https://stackoverflow.com/questions/19493075

 

 

반응형

댓글