writing inner join in wpdb

I have a problem in writing SQL Inner Join syntax in wordpress, This logic should definitely work, I tried this in phpmyadmin and it works fine

SELECT booking_calendars.cal_name
FROM booking_calendars 
INNER JOIN booking_reservation 
ON booking_calendars.id = booking_reservations.calendar_id
WHERE status LIKE 'pending'

but it doesn't in wordpress

$pending_reservations = $wpdb-get_results(" 
    SELECT booking_calendars.cal_name
    FROM'.$wpdb-prefix.'booking_calendars AS booking_calendars
    INNER JOIN' . $wpdb-prefix.'booking_reservation AS booking_reservations
    ON booking_calendars.id =  booking_reservations.calendar_id
    WHERE status LIKE 'pending'");

and then

echo "h2Pending Reservation: /h2br";
        var_dump( $pending_reservations);
        if($pending_reservations0)
        {
        foreach ( $pending_reservations as $pending_reservation ) 
        {
            echo "label". $pending_reservation-cal_name."/labelbr";
        }
    }else{
        echo "labelNo Pending Reservation/labelbr";
    }

I var_dumped $pending_reservations and it returns array(0) { } in wordpress

Topic join-tables mysql wpdb Wordpress

Category Web


thanks for your time and thanks to @czerspalace I started the query with double quotation and then separate it with a single quotation and after looking at the echo output I found that there's no spaces between From and table name

this is the correct way

$pending_reservations = $wpdb->get_results(' 
    SELECT booking_calendars.cal_name
    FROM '.$wpdb->prefix.'booking_calendars AS booking_calendars
    INNER JOIN '. $wpdb->prefix.'booking_reservation AS booking_reservations
    ON booking_calendars.id =  booking_reservations.calendar_id
    WHERE status LIKE "pending"');

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.