1

I am receiving the following:

Error in query:

ERROR: syntax error at or near "Select" LINE 4: (Select remoteaddr, count(remoteaddr) remoteaddrCount

Select Tim1.remoteaddr,Tim1.remoteaddrCount,  Tim2.domain_id
From domain_visitors

(Select remoteaddr, count(remoteaddr) remoteaddrCount
From domain_visitors
Group by remoteaddr
Having count(remoteaddr)>500) Tim1,

(Select distinct remoteaddr, domain_id
From domain_visitors) Tim2
Where Tim1.remoteaddr=Tim2.remoteaddr
2
  • Yes, that is bad syntax alright. If you tell us what you are trying to achieve, maybe someone can help. Commented May 2, 2018 at 11:10
  • You need to JOIN those derived tables somehow. from domain_visitors JOIN (select ...) as tim1 on tim1.some_col = domain_visitors.some_other_col JOIN (select ... ) tim2 on Tim1.remoteaddr=Tim2.remoteaddr Commented May 2, 2018 at 11:23

2 Answers 2

1

It seems like you have exuberancy table name domain_visitors after From and before the sub query.

Let try again with

Select Tim1.remoteaddr,Tim1.remoteaddrCount, Tim2.domain_id From 
(Select remoteaddr, count(remoteaddr) remoteaddrCount From domain_visitors Group by remoteaddr Having count(remoteaddr)>500) Tim1
JOIN 
(Select distinct remoteaddr, domain_id From domain_visitors) Tim2 ON Tim1.remoteaddr=Tim2.remoteaddr

Hopefully this answer will help you.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much
0

You are missing a comma between the 1st table in the FROM and the expression creating Tim1

Select Tim1.remoteaddr,Tim1.remoteaddrCount, Tim2.domain_id 
From domain_visitors,  -- <-- MISSING COMMA 
  (Select remoteaddr, count(remoteaddr) remoteaddrCount 
     From domain_visitors 
     Group by remoteaddr 
     Having count(remoteaddr)>500) Tim1,
  (Select distinct remoteaddr, domain_id 
     From domain_visitors) Tim2 
Where Tim1.remoteaddr=Tim2.remoteaddr

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.