This topic is locked

search results from two different tables

1/31/2016 9:01:04 AM
PHPRunner General questions
R
rishi111983 author

i have a typical problem..i have two tables with different fields ..what i require is to search between these two tables for one common value of name which can be repeated many a times and give a a result row wise from each of these two tables.

alternatively can i search for a result throughout the database

really require some solution

jadachDevClub member 1/31/2016

You can create a union in your database or in the SQL editor.

R
rishi111983 author 1/31/2016



You can create a union in your database or in the SQL editor.


hi i did that but it shows rsults of one table and leaves other blank and creates a single table populating all fields of both tables in single row...

what i requireis like this

table 1 has fields :ser no(auto number) ; name ; date of birth ; place of birth

table 2 has fields ; ser no (auto number) ; name ; place of employment ; date employed on

now amongst these two tables when i search for name in table 1 it should be able to search the name in table 2 also and give results of both . however name cannot be primary key as names can be repeated and it dosent matter if that happens. but i should be able to define parameter search by searchin for values according both the tables field so a specific result may also be achieved.

i hope i am able to convey my problem.any help will be really appreciated i really cannot figure this out

regards

jadachDevClub member 1/31/2016

Create the union like this (sql server)
SELECT

ser_no

,name

,date_of_birth

,place_of_birth

,null as place_of_employment

,null as date_employed_on

FROM dbo.Table1

Union All

SELECT

ser_no

,name

,null as date_of_birth

,null as place_of_birth

,place_of_employment

,date_employed_on

FROM dbo.Table2

R
rishi111983 author 2/1/2016

sorry friend it does not work..u see there is an another issue.. each of these tables is linked with the login table wherein the admin who creates the user enters their full name and address..which are refleted in other tables in list and view through sql query right outer join by selecting these two field...what i think is herein lies the problem...the table 2 also has a details table..

pls help me through this.

regards

jadachDevClub member 2/1/2016

I'm confident you can get this done from the database or sql editor or a combination of the 2. it is too hard from this vantage point to help more. Perhaps support can help.