I prefer to explicitly declare my INNER JOINs (not to imply them by using commas to make a list of tables). That way I avoid accidentally creating any Cartesian products of any tables by leaving out a WHERE condition. Missing ON conditions are much easier to spot (IMHO).
http://dev.mysql.com/doc/mysql/en/JOIN.html SELECT Order.id_order, Employee.name_employee, ItemsOrder.date_order, Unit.name_unit, ItemsOrder.status_order FROM Order INNER JOIN Employee ON Order.emp_id=Employee.emp_id INNER JOIN ItemsOrder ON Order.id_order=ItemsOrder.id_order INNER JOIN Unit ON ItemsOrder.unit_id=Unit.unit_id; Shawn Green Database Administrator Unimin Corporation - Spruce Pine Spenser <[EMAIL PROTECTED]> wrote on 11/04/2004 11:59:16 AM: > The attachment describing your tables didn't come through. However, > here's roughly how your SELECT statement might look: > > SELECT Order.id_order, Employee.name_employee, > ItemsOrder.date_order, Unit.name_unit, ItemsOrder.status_order > FROM Order, Employee, ItemsOrder, Unit > WHERE Order.id_order=ItemsOrder.id_order > AND Order.emp_id=Employee.emp_id > AND ItemsOrder.unit_id=Unit.unit_id; > > Notice that you link the tables together in the WHERE clause based on > common columns between pairs of tables. The columns don't have to have > the same name, just the same information. For instance, if the Order > table has a column called emp_id and the Employee table has a table > called rec_id and both are the employee's identification number, you > would link those two tables together with an equal-sign in the WHERE > clause. For any columns with the same names, put the table name and a > dot before the column name (e.g., Employee.emp_id). > > On Thu, 2004-11-04 at 10:34, Priscilla Labanca wrote: > > The tables are: Order, Employee, ItensOrder and Unit. > > My objective: to program a report of Order that appears > > in the screen the fields > > ( id_order, name_employee, date_order, name_unit and status_order). > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] >