If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > cross platform derived table query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-22-04, 12:05
daytripper daytripper is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
Question cross platform derived table query/subquery in from clause

It's like this, I have a table of searchstrings that I want to list based on unique searchstrings and unique users(because some users search for the exact same thing many times)

table tbl_savesearch
id, searchStr, remote_addr, was_answered

This is the query that works on MS SQL server, but I can't get to work in MySQL:

SELECT ss, COUNT(DISTINCT ra) AS theCount
FROM (SELECT DISTINCT searchStr AS ss, remote_addr AS ra FROM tbl_savesearch) tb
GROUP BY ss
ORDER BY theCount DESC

I checked the mysql documentation and it seems mysql needs to put in an "as" before "tb", but it still won't work.

Is there a standard for this question, some way that I can make it work on both platforms?

Edit: is this thing really called derived table or is it just a subquery? English is not my native language.

Last edited by daytripper; 01-22-04 at 12:11.
Reply With Quote
  #2 (permalink)  
Old 01-22-04, 12:31
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: cross platform derived table query/subquery in from clause

A subquery in the FROM clause is usually called an "inline view" (or at least, it is in Oracle circles). Whether mySQL supports inline views at all, I don't know.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On