This SQL is working fine in mysql for testing purpose, i am getting the street_address_extracted from it
select *, regexp_substr(trim(street_address), '^\\d+\\s+\\w+') street_address_extracted from user_listings WHERE is_found_before = 0
But when i run this query in laravel as i don't get the street_address_extracted field results its always blank but when manually raun into phpmyadmin i get 1000s of rows.
Here is how i wrote this into laravel
DB::select(DB::raw("select *, regexp_substr(trim(street_address), '^\\d+\\s+\\w+') street_address_extracted from user_listings WHERE is_found_before = 0"));
Try this -
DB::table('user_listings')
->selectRaw("*, regexp_substr(trim(street_address), '^\\d+\\s+\\w+') AS street_address_extracted")
->where('is_found_before', 0)
->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.