1. Multi-table join query: When I knew this, I suddenly thought Django was too NX.
Class A (models. Model ):
Name = models. charfield (u'name ')
Class B (models. Model ):
AA = models. foreignkey ()
B. Objects. Filter (AA _ name _ contains = 'searchtitle ')
1.5 I called it reverse query, and then inserted the record 1.5. When I knew it, I instantly felt that Django was too Mrs. NX.
Class A (models. Model ):
The seven latest data records obtained from table Association become one. I can use this statement in phpmyadmin to call up seven results, but in the program, it becomes one.
SELECT fcj. fang_time, fcj. area, fcj. taoshu FROM f_chengjiao AS fcj left join f_city AS fc USING (city_id) WHERE fcj. city_id = 1 order by fcj. fang_time LIMIT 0, 7
Reply to discussion (solution)
Are you sure you want to
Correct statement
1
Update Jytuser
Set Userid
= (
Select Member. userid
From Member
Where Member. ID
= Jytuser. owner_id)
There are two error points:
1) Table auto-join does not seem to work. I guess it will be related to the index changes created during the query.
2) This writing method is not supported by ipvs.
1
Update Jytuser, Member
Set Jytuser. userid
= Member. userid
Where Jyt
Table joins in three different ways: sort merge joins (sort merge join), nested loops joins (Nested Loops join), Hash joins (hash join). 1. Sort merge joins (sort merge Join)
The execution of the sort merge join IS as follows:
*
Table A records the following:AID Anum1 a200501112 a200501123 a200501134 a200501145 a20050115Table B records the following:BID bname1 20060324012 20060324023 20060324034 20060324048 2006032408Create these two table SQL statements as follows:CREATE TABLE AAID Int (1) auto_increment PRIMARY KEY,Anum Char (20))CREATE TABLE
Tags: between union sed ASE str particularity itself equals listTop keywords1 Select 4 with TIES t.title,sum (s.qty) as from sales s2 left JOIN titles T on S.title_ id=t.title_id3GROUP by T.title4 ORDER by TotalSalesView CodeThe top 4 with TIES here is to fetch the first 4 data and require duplicate values, but note that this duplicate value is the row that will affect the returned dataFor example, duplicate values appear in line 4th so that it is pos
Tags: io color ar using SP data div on artIn addition to the usual two table joins, the SQL (MySQL) JOIN syntax also supports multiple table joins. The basic syntax for multiple table joins is as follows:
1
...FROMtable1INNER|LEFT|RIGHTJOINtable2ONconditionINNER|LEFT|RIGHTJOIN table3ONcondition ...
At first we used the most days, and if we didn't have a left join, we'd be like
The code is as follows
Copy Code
Select C.nom, E.nomFrom consultant C, affaire A, besoin B, Salarie SA, site s, entreprise Ewhere c.consultant_id=a.consultant_id and a.besoin_id=b.besoin_id andb.salarie_id=sa.salarie_id and ssa.site_id=s.site_id and s.entreprise_id=e.entreprise_id
It's not as good as green in the left
set (0.00 Secmysql> Next we'll use MySQL's INNER join (or omit INNER using join, same effect) to join the above two tables to read all Runoob_author fields in the Runoob_tbl table in Tcount_ Runoob_count field value corresponding to the TBL table:Mysql>SELECT A.runoob_id,A.Runoob_author,B.Runoob_count fro
Today, while doing a mini-letter wall lottery program, I encountered a problem, I need to query the difference set of scale, the business situation is this
A table is used to save lottery users (www.111cn.net a person may have more than one piece of data), while the other table is saved by the winning users, I need to report the winner of the user to find out, just start with a where to do a multiple
MySQL's left join queries the data from the two tables, with the left-hand table as the main and the right table as a supplement. If there are no contents in the right table in the left table, fill with null. This is the general common explanation. It's easy to understand. B
Tags: filter recommended mysql 2-2 First merge Karl join display1. Preparation of two tables Table A Table B 2. Test the connection query: (1) Cross connection (Cartesian product) SELECT * from a a B
(2) Inner connection Show internal connections SELECT a.*,b.* from a INNER JOIN B on A.age=b.ageb
displ
Access connections can generate a meaningful view or SQL virtual set with the following connections:
Inner JOIN (natural connection): Only rows matching two tables can appear in the result set
Outer joins: include left outer joins (the table on the left is unrestricted), the right outer join (the table on the right is
SQL join: use to query data from these tables based on the relationship between the columns in two or more tables.Join and key: Sometimes we need to get the results from two or more tables in order to get the full result. We need to execute the join. Tables in the database can be linked by keys. The primary key (Primary key) is a column, and the value of each row in the column is unique. In the
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.