Jump to content
  • 0

LEFT JOIN LIMIT


xaero
 Share

Question

У меня есть такой sql код:

select 
sites.*,
cats.cat_id as cat_id,
scats.name as cat_name,
aff.affiliate_firstname as affiliate_firstname,
aff.affiliate_email_address as aff_mail,
afs.view as view,
afs.in_cart as in_cart,
afs.orders as orders,
afs.customers as customers,
afs.date as date,
afs.uniq_hosts_liv as uniq_hosts_liv,
afs.uniq_hosts_ramb as uniq_hosts_ramb,
afs.pages_liv as pages_liv,
afs.pages_ramb as pages_ramb,
afs.tic as tic,
afs.pr as pr
from
affiliate_sites as sites
left join affiliate_sites_to_category as cats on(sites.id=cats.affiliate_site)
left join affiliate_sites_category as scats on(cats.cat_id=scats.id)
left join affiliate_affiliate as aff on(sites.affiliate_id=aff.affiliate_id)
left join affiliate_statistics as afs on(sites.id=afs.affiliate_site)

left join affiliate_statistics as afs on(sites.id=afs.affiliate_site)

в этой таблице очень много записав мне нужно только один запись примерно так: ORDER afs.date DESC LIMIT 0,1

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Может попробовать что-то вроде where afs.date = max(afs.date)? Хотя я не уверен, что он это примет, может быть придётся сделать afs.date = (select max(date) from afs), но я чё-то затрудняюсь представить, что будет на выходе :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy