cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multiple tables selection while using Freehand SQL

manna_das
Contributor
0 Likes
783

Dear All,

How to select multiple tables in Freehand Sql. I am not able to select multiple tables.

Kind Regards

Manna Das

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi,

As suggested above try Join conditions. If you don't know how, go to:

http://www.w3schools.com/sql/

It's a quite good tutorial, you should find what you need there.

Regards,

Bartłomiej.

manna_das
Contributor
0 Likes

Thanks for the quick reply, but I have three tables to join, what would be the syntax for that?

Kind Regards

Manna Das

Former Member
0 Likes

Should be something like this.

SELECT * FROM table1
JOIN table2 ON foreign_key1_from_table1 = main_key_from_table2

JOIN table3 ON foreign_key2_from_table1 = main_key_from_table3.

Former Member
0 Likes

also check this, googling is not that hard

http://stackoverflow.com/questions/9853586/sql-join-multiple-tables

I hope that I've helped.

Answers (3)

Answers (3)

Former Member
0 Likes

hi all,

Is Freehand sql different from native sql?

Henry_Banks
Product and Topic Expert
Product and Topic Expert
0 Likes

No. "freehand" just means it's the user that is typing the syntax in manually, rather than it being generated by a semantic layer (for example)

Former Member
0 Likes

Hi Henry,

So we need to write sql's as we write in Oracle/sql server? By this systax changes for different databases?

Also can you please suggest on using the below bolded sql's with below table structures? For the above mentioned scenario.

emp ---------------> empId-empName-empSal-deptId

dept ---------------> deptId-deptName-deptMngr-deptHrId

hr ---------------> hrId-hrName

first find the numberr of entries by using this query

select d.deptId,d.deptName,d.deptMngr,h.hrName from dept d,hr h
where d.deptHrId=h.hrId

next depending upon the result

select
e.empId,e.empName,e.empSal,dh.deptName,dh.deptMngr,dh.hrName

from emp e, (select d.deptId,d.deptName,d.deptMngr,h.hrName from
dept d,hr h where d.deptHrId=h.hrId) dh

where e.deptId=dh.deptId

If we want using joins

select e.empId,e.empName,e.empSal,d.deptName,d.deptMngr,h.hrName

from emp e

inner join dept d on e.deptId=d.deptId

inner join hr h on h.hrId=d.deptHrId

TIA.

manna_das
Contributor
0 Likes

Hello thanks for the reply. I tried a lot but its not working, the query only reads the first line, even if i change the line it does not work

Kind Regards

Manna Das

Former Member
0 Likes

Could you paste here the entire query?

manna_das
Contributor
0 Likes

Hello Bartlomiej,

This is the entire query. Pasted above.

Kind Regards

Manna Das

Former Member
0 Likes

I'm guessing it shows you only the fields you've selected from Account. Try adding the columns from Contact and from Opportunity for example

Select col1.Account col2.Account col1.Contact col1.Opportunity from Account

Join Contact...

Join Opportunity...

Just like in the tutorial I've sent you. They're example is like this:

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate

FROM Orders

INNER JOIN Customers

ON Orders.CustomerID=Customers.CustomerID

Note that they use fields from the joined tables after the word "SELECT" in the select statement.

Let me know if this solves your problem.

Regards,

Bartłomiej.

Henry_Banks
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi,

I'd recommend using SQL Join conditions.

regards,

H