A simple join would work for this as well:
SELECT * FROM employees, departments WHERE employees.deptid =
departments.deptid
As a bonus, this way you could easily pick what fields you wanted from
each table. For example:
SELECT employees.id,employees.name,departments.name FROM employees,
departments WHERE employees.deptid = departments.deptid
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: [email protected]
Web Site: http://www.sonsothunder.com/
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution