Laravel 4 Query Designer does not support more than one table in the "from" section

Is there a way to generate an SQL query in Laravel 4 (using the query builder) that supports more than one table in a "from" clause without using joins?

I want to do something like this:

SELECT * FROM table_1 as t1, table_1 as t2... 

Can this be done without using joins? I noticed that the from () method breaks something after the table name / alias:

 ->from('table_1 as t1, table_1 as t2') 

becomes (yes, with a comma at the end):

 table_1 as t1, 

Thanks for any help.

+6
source share
1 answer

The OP answered and updated his question. To get a clearer answer, follow these steps:

Antonio Carlos Ribeiro - thanks for the answer, but as I wrote in the question, I tried to avoid using joins, since I have a complex query, but it does not use joins (and there is a reason for this).

I managed to do it myself :) In fact, it was quite simple: all I had to do was use DB:raw() , which allows us to inject the unformatted part of the request:

 ->from(\DB:raw('table_1 as t1, table_1 as t2')) 
+1
source

Source: https://habr.com/ru/post/950308/


All Articles