Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use oinSub syntax in Laravel

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to use oinSub grammar in Laravel". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I have a sentence, thinking that the join subquery does not support the writing of the model query. Baidu found that there is a syntax of joinSub, so I hereby record it.

The purpose of the following statement is to take the one with the latest date in the whole table (only the latest when there are duplicates in the same field)

I didn't set the capitalization of the table field. I'm just querying the user.

ResultIds = DB::connection ('fund')-> select ("SELECT t1.InvestAdvisorCodeFROM table T1 INNER JOIN (SELECT SUBSTRING_INDEX (group_concat (id ORDER BY EndDate DESC),',', 1) AS id FROM table T2 GROUP BY InvestAdvisorCode) T2 ON t1.id = t2.idorder by t1.TotalFundNV desc") $subQuery = Table::query ()-> selectRaw ("SUBSTRING_INDEX (group_concat (id ORDER BY EndDate DESC),',', 1) AS id")-> from ('table as T2')-> groupBy ('InvestAdvisorCode')-> getQuery () This is the end of the introduction of $resultIds=Table::query ()-> from ('table as T1')-> joinSub ($subQuery,'t2','t1.id','=','t2.id')-> orderBy ('t1.TotalFundNV grammar grammars')-> pluck ('InvestAdvisorCode')-> toArray () "how to use oinSub Grammar in Laravel". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report