Converts SQL statements to LaravelORM.

Source: Internet
Author: User
How should I write the SQL statement {code...} into an ORM. Laravel is not used much. Please give me some advice .. If I step on my friends, what is the question I asked? You can answer the question. What kind of mentality can't I answer .?
SELECT    e.external_account_id,    e.trade_type,  e.stock_code,    e.name,    e.stock_name,    SUM(e.trade_price * e.trade_count) / SUM(e.trade_count) AS trade_price,    SUM(e.trade_count) AS trade_countFROM    (        SELECT            a.id,            a.external_account_id,            a.internal_account_id,            a.trade_price,            a.trade_count,            b.stock_code,            b.trade_type,            c.name as stock_name,            d.name        FROM            trades a,            orders b,            stocks c,            external_accounts d        WHERE            a.order_id = b.id        AND b.stock_code = c.code        AND a.external_account_id = 29        AND d.id = 29    ) AS eGROUP BY e.stock_code, e.trade_type

How should I write this SQL statement into an ORM? =.
Laravel is not used much. Please give me some advice ..

If I step on my friends, what is the question I asked? You can answer the question. What kind of mentality can't I answer .?

Reply content:
SELECT    e.external_account_id,    e.trade_type,  e.stock_code,    e.name,    e.stock_name,    SUM(e.trade_price * e.trade_count) / SUM(e.trade_count) AS trade_price,    SUM(e.trade_count) AS trade_countFROM    (        SELECT            a.id,            a.external_account_id,            a.internal_account_id,            a.trade_price,            a.trade_count,            b.stock_code,            b.trade_type,            c.name as stock_name,            d.name        FROM            trades a,            orders b,            stocks c,            external_accounts d        WHERE            a.order_id = b.id        AND b.stock_code = c.code        AND a.external_account_id = 29        AND d.id = 29    ) AS eGROUP BY e.stock_code, e.trade_type

How should I write this SQL statement into an ORM? =.
Laravel is not used much. Please give me some advice ..

If I step on my friends, what is the question I asked? You can answer the question. What kind of mentality can't I answer .?

Converting to An ORM increases complexity and reduces the readability of SQL statements.DB::select()To execute SQL.

Complex SQL statements do not need to be changed to orm.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.