2017-06-13 85 views
0

我想在內部連接條件語句中的數據庫中的字符串中搜索變量。我想在ign_product_level_%_pricewp_idpl_orders.product_id%在下面的查詢。我怎樣才能做到這一點?在內部連接條件語句中連接字符串中的變量

SELECT * FROM `wp_idpl_orders` INNER JOIN wp_postmeta WHERE wp_postmeta.meta_key like "ign_product_level_%_price" and wp_postmeta.meta_key like wp_idpl_orders.product_id and wp_postmeta.post_id = wp_idpl_orders.post_id 

回答

0

MySQL CONCAT()函數用於添加兩個或多個字符串。

SELECT * FROM `wp_idpl_orders` INNER JOIN wp_postmeta WHERE wp_postmeta.meta_key like concat("ign_product_level_",wp_idpl_orders.product_id,"_price") and wp_postmeta.post_id = wp_idpl_orders.post_id