I have 2 tables and I need to select the relative information, need some help with the query.
Table 2 has ID
, MaskID
columns.
The TSQL query would be:
SELECT t2.ID, t3.MaskName, t3.Total
FROM Table2 AS t2 INNER JOIN Table3 AS t3 ON (t2.MaskId = t3.MaskId)
WHERE ID = 123
Unsure what you mean by 'traverse' through them.
select ID, MaskName, Total from TABLE_2
inner join TABLE_3 on (TABLE_2.MaskID=TABLE_3.MaskID)
where ID=111
You may want to use a Join in your sql query. The w3schools site has a page explaining how to use it.
SELECT t2.ID,t3.MaskName,t3.Total
FROM Table2 t2 INNER JOIN Table3 t3
ON t2.MaskID=t3.MaskID;
you shoud use this query
select ID,MaskName,Total from Table1 Inner join Table2 on Table1.MaskID = Table2.MaskId where ID = "given value"
SELECT a.ID, b.MaskName, b.Total from 2 a INNER JOIN 3 b ON a.MaskID=b.MaskID WHERE ID='Given value'
This is a simple MySQl/T SQL/ PLSQL query. Just use an INNER JOIN on the two tables. A Join works by combining the two tables side by side. The INNER JOIN only outputs the result of the intersection of the two tables. That is, only those rows where the primary key and foreign key have a matching value.
In certain cases, you may want other rows outputted as well, for such cases look up LEFT JOIN, RIGHT JOIN and FULL JOIN.