I have a custom table "orders" in which I save orders data.
| id | user_id | product
In this way, I get data from it.
$orders = $wpdb->get_results(
"
SELECT *
FROM sbgf_pl_orders
ORDER BY ID DESC
LIMIT 500
");
foreach ( $orders as $order ){
echo $order->id;
}
I want to link my request with user_meta table so that I would get orders from those users whose profile has a specific delivery method as suer meta "shippment_method".
I tried this, but this request overloads my site
$orders = $wpdb->get_results(
"
SELECT *
FROM sbgf_pl_orders, sbgf_user_meta
WHERE sbgf_user_meta.shipping_method = '1' AND sbgf_user_meta.user_id=sbgf_user_meta.user_id
ORDER BY ID DESC
LIMIT 500
");
foreach ( $orders as $order ){
echo $order->id;
}