Home > Software design >  how to get data from 2 diffrent db tables and join together mysql query
how to get data from 2 diffrent db tables and join together mysql query

Time:10-28

am working on a project where I need data from two different tables am confused about how to write a query for it, Please help me if possible. MYSQL query

table 1 : stagingScriptDB 
table 2 :testBedSuiteMapping 

I need all data from stagingScriptDB and only tamplate field from testBedSuiteMapping. stagingScriptDB fields idScriptDB
| scriptName
| platform
| scriptArea
| newArea
| subArea
| module
| component
| minRel
| suiteInfo
| totalTC
| runTime
| status
| scriptSubmitter
| updated_ts
| projectarea and
testBedSuiteMapping fields:- testBedName
| relInfo
| regType
| area
| platform
| suites
| template
| block
| updated_ts
| id

CodePudding user response:

You need to do a join of the tables. Do they have a link field? "testBedSuiteMapping" must have some foreign key.

then it would be like this

select stagingscriptdb.*, testbedsuitemapping.yourfield
from stagingscriptdb
inner join testbedsuitemapping on testbedsuitemapping.id = stagingscriptdb.id_stagingscriptdb
  • Related