2015-10-02 107 views
0

我想從MySQL數據庫拉一些數據作爲Wordpress網站的一部分,將其移動到一個新的WordPress的網站。MySQL的WordPress的數據搜索查詢

我試圖搶在某一類別的所有訊息,這樣我可以出口。用簡單的英語,我想做到以下幾點:

  1. 在表wp_term_relationships表中獲取該關聯與term_taxonomy_id「17」
  2. 然後所有的OBJECT_ID號碼的清單 - 在wp_posts搜索具有ID所有行=到的object_id列表從點1

我不介意手動建立一個搜索項,從第1點得到的條目,因爲只有88,如果它更容易跳到第2點?

我使用續集專業& mysqlworkbench查詢工具來訪問數據庫&導出/導入&操縱數據。

感謝

UPDATE這裏是我到目前爲止有:

SELECT * FROM `wp_posts` WHERE `ID` = '535' ORDER BY `post_author` LIMIT 0,1000 

我要有效地搜索ID 535,536,153,等...

回答

0

OK,想通了:

SELECT * 
FROM `wp_posts` 
WHERE 
(
    (`ID` = '535') OR (`ID` = '539') OR (`ID` = '803') OR (`ID` = '919') OR (`ID` = '958') OR (`ID` = '1188') OR (`ID` = '1284') OR (`ID` = '1287') OR (`ID` = '1332') OR (`ID` = '1359') OR (`ID` = '1378') OR (`ID` = '1450') OR (`ID` = '1474') OR (`ID` = '1543') OR (`ID` = '1547') OR (`ID` = '1556') OR (`ID` = '1573') OR (`ID` = '1596') OR (`ID` = '1598') OR (`ID` = '1677') OR (`ID` = '1706') OR (`ID` = '1708') OR (`ID` = '1813') OR (`ID` = '1868') OR (`ID` = '1956') OR (`ID` = '1979') OR (`ID` = '2013') OR (`ID` = '2020') OR (`ID` = '2089') OR (`ID` = '2159') OR (`ID` = '2201') OR (`ID` = '2231') OR (`ID` = '2243') OR (`ID` = '2409') OR (`ID` = '2506') OR (`ID` = '2572') OR (`ID` = '2721') OR (`ID` = '3337') OR (`ID` = '3421') OR (`ID` = '3481') OR (`ID` = '3625') OR (`ID` = '3701') OR (`ID` = '3706') OR (`ID` = '4013') OR (`ID` = '4182') OR (`ID` = '4276') OR (`ID` = '4328') OR (`ID` = '4373') OR (`ID` = '4405') OR (`ID` = '4438') OR (`ID` = '4506') OR (`ID` = '4565') OR (`ID` = '4628') OR (`ID` = '4681') OR (`ID` = '4732') OR (`ID` = '4767') OR (`ID` = '4836') OR (`ID` = '4920') OR (`ID` = '4968') OR (`ID` = '5017') OR (`ID` = '5038') OR (`ID` = '5115') OR (`ID` = '5144') OR (`ID` = '5215') OR (`ID` = '5244') OR (`ID` = '5318') OR (`ID` = '5339') OR (`ID` = '5384') OR (`ID` = '5406') OR (`ID` = '5450') OR (`ID` = '5515') OR (`ID` = '5821') OR (`ID` = '6070') OR (`ID` = '6178') OR (`ID` = '6238') OR (`ID` = '6288') OR (`ID` = '6355') OR (`ID` = '6510') OR (`ID` = '6612') OR (`ID` = '6690') OR (`ID` = '6756') OR (`ID` = '6776') OR (`ID` = '6792') OR (`ID` = '6822') OR (`ID` = '6835') OR (`ID` = '7631') OR (`ID` = '8241') OR (`ID` = '8671') 
) 
ORDER BY `post_author` 
+1

您應該閱讀['IN'](https://dev.mysql.com/doc/re FMAN/5.1/EN /任何功能於一些-subqueries.html)。 – George

+0

謝謝喬治 - http://www.tutorialspoint.com/mysql/mysql-in-clause.htm –