Another SQL question

Ken Ray kray at sonsothunder.com
Thu Feb 5 04:18:10 EST 2009




On 2/4/09 1:33 PM, "Bob Sneidar" <bobs at twft.com> wrote:

> So using your method, my queries for a table of 25 employees with the
> associated departments data would look something like this:
> 
>   -- employee data
> put "SELECT employees.deptid FROM employees LIMIT 25" into
> mEmployeeQuery
> 
> -- department data
> put "SELECT * FROM departments WHERE departments.deptid IN (" &
> mEmployeeQuery & ")" into mDepartmentQuery

Actually, Bob, you don't need to do two queries... you can do it in one...
also, you don't need to use LIMIT unless you specifically want less records
than what would normally be returned:

SELECT * FROM departments WHERE departments.deptid IN (SELECT
employees.deptid FROM employees)

HTH, 

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list