Skip to content
Advertisement

SQL Combining two different tables

(P.S. I am still learning SQL and you can consider me a newbie)

I have 2 sample tables as follows:

Table 1

Table 2

My scenario is, from the 2nd table, i need to fetch all the records that contain a certain word, for which i have the following query :

(Note that i am setting the OFFSET due to requirements.)

Now, the scenario is, as soon as i retrieve 1 record from the 2nd table, i need to fetch the record from the 1st table based on the Profile_Id.

So, i need to return the following 2 results in one single statement :

And i need to return the results in side-by-side columns, like :

(Note i had to merge 2 Profile_Id columns into one as they both contain same data)

I am still learning SQL and i am learning about Union, Join etc. but i am a bit confused as to which way to go.

Advertisement

Answer

You can use join:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement