This SQL statement can be queried by different fields of different languages of different tables, and which record can be partially belonging to?
Two tables
The Table1 structure is as follows
IDTITLECONTENT
The Table2 structure is as follows
IDCONTENTBIGCLASSMALLCLASSSSSMALLCLASS
SQL = "SELECT ID, TITLE, Content, 'AS Bigclass,' AS SmallClass, 'TBL1' AS TBL from Table1 Where Title Like '%" & Keyword & "%' OR Content Like '%" & Keyword & "%" UNION SELECT ID , 'AS Title, Content, Bigclass, Smallclass,' TBL2 'As TBL from Table2 Where Content Like'% "& Keyword &"% 'Order BY ID DESC "
This statement can realize the query.
Taking ASP as an example, pass
SET RS = Conn.execute (SQL)
While Not Rs.eof
......
......
Response.write RS ("TBL") 'This value is the determination of which table is
......
......
rs.movenextwe
Analysis of the above SQL statement, in fact, through AS, unify the field names in the two tables, the number of fields is not enough (''), that is, the blank string instead, of course, if you are willing, you can use non-empty skewers. ('this is bigclass belong to Table2'), which is also convenient for which table in which table is distinguished. This SQL statement is cleverly uses the 'TBL1' AS TBL this to determine which table belongs to, in order to process the data, especially for the site search, search the results in one page when searching the different tables, according to different tables Passing different ID values into different tables corresponding to the display page, some to use readnews.asp to use Other.asp this page, which is very convenient.
Welcome everyone to discuss!