database - LIMITing an SQL JOIN -


I am trying to limit the following SQL statements.

  SELECT expense. *, transaction . * Expense_id = transaction_expense_id  

To limit the number of 'parent' rows, by spending on INNER join transactions. If I make a limit of 1, I will get only one expense, but still will get all the transactions associated with it.

How will this get?

At this level, if I get 1, I get an expense, and only get one transaction.

So suppose we can exclude the user, it can be rewritten in the form of a table Select

  from the expense, the transaction where expense_id = transaction_expense_id  

Now if you want to apply a limit, you

What to do: Choose

 , expense transaction, where expense_id = transaction_expense_id and expense_id (expense_id's spending limit to choose from 1) What did you want? Obviously you should be careful that in what order your expense_its are coming back, you probably want to use the ORDER.  

Edit: Looking at the MySQL limit described in your comment below, perhaps this work:

 Choose from  (choose from ID from 1 to Cement 1 till the order) As T1, transactions where expense_id = transaction_expense_id;  

Ben


Comments