我想在内连接条件语句中搜索数据库中字符串中的变量。我想在wp_idpl_orders.product_id
的{{1}}中使用%
替换ign_product_level_%_price
。我怎么能这样做?
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 :(得分: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