Venkata Guntupalli said: Hi,I have to convert the given SQL into cognos report without changing any of the functionality included in SQL. The SQL looks like having involved with Subquery and filters on indivual columns. The report will need a date range prompt. In the attached SQL, I have hardcoded the Date range (between starting date to ending date) values in To_date function where in cognos report those values have to dynamically come from prompt page selection, so assume it will be like, to_date('date parameter value','dd-mm-yyyy').Pls let me know if I have to provide more information
I have a need to pre-filter a Query Subject in my Presentation layer using a Subquery...SQL example (simplified):Select from ALL_ASSIGNMENTS Where EFFECTIVE_END_DATE = ( Select Max(ALL_ASSIGNMENTS_1.EFFECTIVE_END_DATE) From ALL_ASSIGNMENTS ALL_ASSIGNMENTS_1 Where ALL_ASSIGNMENTS.PERSON_ID = ALL_ASSIGNMENTS_1.PERSON_ID) My first step was to change the SQL definition in the Query Subject (which I've done many times before), however a Bug is present (V8.4 FP2) which produces an error related to Cognos using the 'WITH' clause, and I need to change the query properties to prevent Cognos from using
Is there any way to convert this subquery to a join? Does it even work in MySQL? or might be wrong to start of with :) SELECT p.pollID, p.thepoll, a.answerID, a.answer FROM polls AS p, pollAnswer AS a WHERE p.pollID = SELECT MAX(pollID) FROM polls; What I want to do is to get the last inserted row along with the data that belongs to that row from another table.
I have to move my site to another host that doesn't support subquery (v4.0). I'm having a problem with rewriting a subquery, and I'm wondering if there's any workaround for this problem. I'd really appreciate any helps. Say I have a category table with 2 fields (catID, and catName): A a B b C c D d And another item table with 2 fields (itemID and catName (references the category table)): 1 A 2 C 3 B 4 B 5 B I need to write a query to produce a listing of each category from the category table along with the number of items it has, e.g.: A 1 B 3 C 1 D 0 I can write this with subquery, but I'm re
Please point me where is the SQL syntax error here: SELECT date FROM `cart` WHERE id = (SELECT max(id) FROM `cart` WHERE session = "0e74401d62ad0c25dce17e17726b74cf"); Separately both querys work, if i substitute the subquery with it's result (id=34). Dmitri/dts
How is memory managed for subqueries? Are the temporary tables created from a subquery loaded into memory in any way? For example: <code> SELECT * FROM ( SELECT * FROM super_big_table ) AS too_big_table LIMIT 1 </code> Will this code load all of super_big_table into memory, or is MySQL smart enough to only load the first row? I have some subqueries that might be pretty big and I want to make sure they won't cause any problems.
Hi, I am using MySQL 4.0.23_Debian-7 and I try to use subquery with "IN" E.g. SELECT s1 FROM t1 WHERE s1 = ANY (SELECT s1 FROM t2); SELECT s1 FROM t1 WHERE s1 IN (SELECT s1 FROM t2); from the manual Both of these types of queries return this error message: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Select .... ErrorNr. 1064" The sql example 'SELECT s1 FROM t1 WHERE s1 IN (SELECT s1 FROM t2)" is from the correct version manual of the server. When I try to use the same query with
I have a probleme with a very simple subquery: SELECT a, b, c, FROM ( SELECT role AS a, otherAttr AS b, COUNT( * ) AS c FROM `target` GROUP BY role, otherAttr ) AS test WHERE c >19 (Actually, what I want it to show the results of the count over 19) Can somebody told me why it's not working ? I have a syntax error: #1064 - Erreur de syntaxe pr�s de 'FROM (SELECT role AS a, otherAttr AS b, COUNT( * ) AS c FROM `t' � la ligne 1 I have a MySQL 4.1.9-max server running with easyphp-1.8 Thx
Any ideas why this works:SELECT NETINT.NETWORKIDFROM MSTRESRC.NETWORKINTERFACES AS NETINTLEFT OUTER JOIN MSTRESRC.NETWORKS AS NETWORK ON NETWORK.NETWORKID=NETINT.NETWORKIDWHERE NETINT.NODEID=8713ORDER BY NETWORK.NETMASK FETCH FIRST ROW ONLYbut this does not:SELECT HOSTNAMEFROM MSTRESRC.NETWORKINTERFACESWHERE NODEID=8713AND NETWORKID=(SELECT MSTRESRC.NETWORKINTERFACES.NETWORKID FROM MSTRESRC.NETWORKINTERFACES AS NETINTLEFT OUTER JOIN MSTRESRC.NETWORKS AS NETWORK ON NETWORK.NETWORKID=NETINT.NETWORKIDWHERE NETINT.NODEID=8713ORDER BY NETWORK.NETMASK FETCH FIRST 1 ROWS ONLY)I intend to use the seco
I am having difficulty in the following subquery. I keep getting the syntax error at 'SELECT count(*)'. SELECT ID, organization, (SELECT count(*) FROM Invoices WHERE paid = 'N') AS paid FROM clients What I am trying to do is to get a list of clients and also count any unpaid invoices.
i'm having problems executing a db2 query in my IBM DB2 command center v7.i'm trying to execute a select statement with a subquery. i constructed it like this:SELECT DISTINCTCOMPUTER_SYS_ID,(Select MANUFACTURER from PROCESSOR_DATA_VIEW where PROCESSOR_NUM=1 AND COMPUTER_SYS_ID = T1.COMPUTER_SYS_ID FETCH FIRST ROW ONLY) AS PROCESSOR1FROMPROCESSOR_DATA_VIEW as T1GROUP BYCOMPUTER_SYS_ID---> but it doesn't work. the equivalent statement (that works) of this in SQL is:SELECT DISTINCT COMP_SYS_ID,(SELECT TOP1 MANUFACTURER + ' ' + LTRIM(STR(MAX_SPEED))FROM PROCESSOR_DATA_VIEW WHERE PROCESSOR_NUM=1
It is the following one... I do not know if it is the version of mysql, but I do not obtain to make subquery's Help Please!!!!
System: MySQL 4.0.25 I have 2 tables: table1: name A B C table2: name1 name2 A Z B A A C I want to select all lines from table2 where name1 and name2 are in table1. Then, in my example, the last two lines of table2 would be selected. What is the corresponding SELECT instruction to make this without using a subquery. Any help would be very appreciated,
Hello, I am working with a website that I am creating using mySQL and PHP. My issue involves a subquery along with the max() function. So, if you have experience with those, please read on ... I would very much like to solve this query, I've been working long and hard on this. Here is the Database information. Database name is "geonap_admin", table is "log" and the fields/columns I am dealing with are (1) geocache_name, (2) coin_id, (3) log_id. I also have a few other fields including log_date in the database, but for now, just focusing on those fields until I can solve. To
Hello, I am studying mySQL and now I am practicing with the subquerys on examples of Data bases. My issue involves a subquery along with the AVG() function. I've been working on this, but I can´t resolve it. Here is the information: Table Employees with the fields/columns: EmployeeID (The PK), LastName, FirstName and a few other fields. Table Orders with the fields/columns: OrderID (The PK), CustomerID, EmployeeID, OrderDate and a few other fields. Table order_details with the fields/columns: OrderID (PK), ProductID (PK), UnitPrice and Quantity. I am looking for the last name and name of the
SELECT domainTable.name as domain, sum(NetworkTraffic.upload) as Upload, sum(NetworkTraffic.download) as Download, sum(NetworkTraffic.upload) as Upload2 sum(NetworkTraffic.download) as Download2 FROM `NetworkTraffic` LEFT JOIN domainTable ON domainTable.domainId = NetworkTraffic.domainId WHERE NetworkTraffic.protId=2 AND date between "2005-10-11" AND "2005-10-18" GROUP BY domainTable.name I am using the left-join above to merge two tables (NetworkTraffic and domaintable) on domainId to find which domain to present. By doing this i summarize the download and upload from Netw
We have recently upgraded from Cognos 7.1 to 7.3 for use with DB2 and upon finalising installation, have discovered that the PPAdminTool.exe program which was originally included in 7.1, is not included in the 7.3 install.We require the PPAdminTool.exe to disable cognos cubes whilst refreshing them.So two questions;a) Is there a PPAdminTool.exe for Cognos 7.3?If not;b) Can the PPAdminTool.exe which came with Cognos 7.1, be used for 7.3, is there any compatibility issues?Much
I am having a trouble with concat_ws. Consider the following example (table type is innoDB): CREATE TABLE person ( id INTEGER(3) AUTO_INCREMENT, name VARCHAR(10), CONSTRAINT pk_person PRIMARY KEY (id) ); CREATE TABLE telephone ( telephone_id CHAR(6), tel_no CHAR(7), CONSTRAINT pk_telephone PRIMARY KEY (telephone_id, tel_no) ); INSERT INTO person (name) VALUES ('jack'); INSERT INTO person (name) VALUES ('john'); INSERT INTO person (name) VALUES ('bruno'); INSERT INTO person (name) VALUES ('daisy'); INSERT INTO person (name) VALUES ('kelly'); INSERT INTO telephone VALUES ('1', '5675431'); INSERT
I have a server using MySQL 4.0.23 (and no I can't upgrade it). I am trying to write some code for a report that I need and I'm having a syntax problem (at least thats what the server tells me) with a simple subquery using the "IN" operator. Below is am example... select Id from tempSTR where Id IN (select max(Id) from tempSTR); This query works fine under MySQL 5 but not on the antiquated version I am forced to use. Anyone have any ideas or know of a way around the problem?
can anyone help me to rewrite the query below. If I run it as it is I get the following error: ""1235 This version of mysql doesn't yet support 'Limit & IN/ALL/ANY/SOME subquery". The problem is the LIMIT statement in the subquery. However, I don't have a clue how to do the intended selection without a subquery that contains a LIMIT. (I'm running MySQL-server-standard 5.0.16-0 on SUSE Linux 10) SELECT t1.Date FROM t1 WHERE (t1.ID =ANY(SELECT t1.ID FROM t1, t2 WHERE (t1.PlaceID = t2.ID) AND (t1.Date < '2005-05-01') AND (t2.Country = 300) ORDER BY t1.Date DESC LIMIT 90)) AN
I have trouble making the following "table subquery" work. When run alone, the inner query, returns 25 results (each consisting of disciplinid and minimum score) as expected. When the entire query is run, however, only seven results are returned. This is quite weird, since the inner query is merely a restricted version of the outer. I tried using aliases such that the field names that are matched between inner and outer query have the same names, but that yields no changes at all. Could someone give me a hint, please. Thank you very much (in advance) . SELECT DISCIPLINER.disciplinnav
I have 2 tables an item table and a stones table: CREATE TABLE items ( id int(11) NOT NULL auto_increment, sold int(1) NOT NULL default '0', stocknum varchar(10) default NULL, name text, type text, image text, description text, comments text, retailPrice float(5,2) NOT NULL default '0.00', tagPrice float(5,2) NOT NULL default '0.00', metalCost float(5,2) NOT NULL default '0.00', labor float(5,2) NOT NULL default '0.00', markup float(5,2) NOT NULL default '0.00', metal text, imageThumb text, PRIMARY KEY (id), KEY stocknum (stocknum,retailPrice,tagPrice), KEY sold (sold) CREATE TABLE stones ( id
I trying to use a simple subquery to find out the highest primary key in a table and print all of the results other than that one, but I keep getting a syntax error related to the subquery and I have no Idea why... Does anybody know what I'm doing wrong? Here is the code: SELECT * FROM sm_articles WHERE articles_pk < (SELECT MAX(articles_pk) FROM sm_articles) the table has 4 columns which are; articles_pk, articles_title, articles_date, articles_text. Many
Is it possible to return multiple rows from a select statement as a single string? Example: SELECT item, (some subquery) as transaction, price from myTable Desired result: item transaction price 'cd gem case' '00167,00174,00211' .38 The transaction field would represent multiple values returned by the suquery.
HiI want to use Cognos Impromptu.I have query about creating Catalogs in impromptu.Is it possible to create Database in impromptu using two databases from MS SQL database.For example I want to create database in Impromptu with master and msdb fro MSSQL so I can create report with data from master and msdb tables.I want to create report from two tables of mssql which are in differennt database schema of MSSQL.is it possibel to achieve this?how can I create such a catalog?
I was knocking my head on this subquery syntax for an hour trying to figure out why it's returning a syntax error: SELECT productid, product FROM products WHERE productid NOT IN (SELECT productid FROM order_details WHERE orderid=824790); Then, quite suddenly, I discovered that the system I'm trying to make it work on is running MySql 3.23.58 with no chance of upgrading to a more reasonably recent version. I know that it should be possible to do the same query using joins, thereby avoiding the subquery altogether, but that's one aspect of SQL that I've never really delved into and I'm not sure
I have situation similar to one I saw posted here. He didn't get answer, he had to write app code to do what he wants I think my answer is the same... :( Here is the situation I inherit this dataset and it is not scaling well as the data tables grows. We have people and we have a large selection of skills that they might be evaluated on. We also have a table that tells which people participate in which skills and which should be use to govern whether a skill evaluation is created for a person or not, but it is not. The person who create this didn't know about left join I guess ?? , he create a
Here is my DELETE statement that should work but doesn't due to "Currently, you cannot delete from a table and select from the same table in a subquery. " DELETE FROM history WHERE eventTime = (SELECT MIN(eventTime) from history) I found information about selecting the max with a subquery here: http://dev.mysql.com/doc/refman/5.0/en/example-maximum-row.html but it's no help with this. I also checked the doc for DELETE and their comments didn't seem to apply to this. So do I absolutely have to use my code to do a SELECT, then a DELETE on the specific eventTime I found with MIN?
I have a table CREATE TABLE `Pricing` ( `Size` smallint(6) NOT NULL default '0', `Qty` int(11) NOT NULL default '0', `Single` double NOT NULL default '0', `Additional` double NOT NULL default '0', KEY `Size` (`Size`,`Qty`) ) TYPE=MyISAM; The following sub-query does not work in MySQL 4.0.25. Can someone help me to convert it to a non-subquery. Thanks a lot. SELECT * FROM 'Pricing' WHERE Size = (SELECT Min( Size ) FROM `Pricing` WHERE Size >= 1.2) AND Qty = (SELECT Max( Qty ) FROM `Pricing` WHERE Qty <= 130)
I always get an error with the following delete-constraint (constraint includes three tables LEKTION, SACHVERHALT and MEDIEN_SACHVERHALT): DELETE FROM MEDIEN_SACHVERHALT WHERE sachverhaltKey = (Select t3.sachverhaltKey FROM LEKTION t1, SACHVERHALT t2, MEDIEN_SACHVERHALT t3 WHERE t1.lektionKey = 276 AND t1.lektionKey = t2.lektionKey AND t2.sachverhaltKey = t3.sachverhaltKey); when I only unse the inner query, it works fine (let's say, it gives me 39 as a result): Select t3.sachverhaltKey FROM LEKTION t1, SACHVERHALT t2, MEDIEN_SACHVERHALT t3 WHERE t1.lektionKey = 276 AND t1.lektionKey = t2.lekt
I am having a problem converting this subquery to a join. I want all the rows from t1 that match the substring in t3. SELECT count(*) FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2 WHERE t2.b IN (SELECT t3.b from t3 WHERE MATCH (t3.matchname)AGAINST('a string ' IN BOOLEAN MODE ))); If I write the join this way, I get the same results (what I want): SELECT * FROM t1 where t1.a IN ( SELECT t2.b FROM t2 INNER JOIN ( SELECT b from t3 WHERE MATCH (matchname) AGAINST('a string ' IN BOOLEAN MODE ) )AS tt1 on t2.b = tt1.b ); My problem occurs when I try to change the "select..where IN" part. I c
I have a table that is called "threads". It contains within it "posts" and some of those posts are categorized as threads by the thrdtype column. This is to notify that that post is the first post in a specific thread and then other posts are attached to it using the unique thrdid. Posts are attached to threads, and threads are attached to forums via frmid. What I need to do is find the latest post (not thread) in a given forum, but I need to do so whilst placing restrictions on the parent thread that exists within the same table (such as what forum to look for the threads
Hello, I have a major problem whitch I have to fix ASAP.. Here's the deal: select count(1) from Dossiers d where d.no in( select b.dossier_no from Dossiers dd,dossiers_owner_bridge b, users u where u.id=b.user_id and b.dossier_no=dd.parent and u.username like 'SI%' group by b.dossier_no ) the following sub query return one row: mysql> select b.dossier_no from Dossiers dd,dossiers_owner_bridge b, users u -> where -> u.id=b.user_id -> and b.dossier_no=dd.parent -> and u.username like 'SI%' -> group by b.dossier_no -> ; +------------+ | dossier_no | +------------+ | 12435 | +
SELECT * FROM (SELECT CONCAT(comments.category,'s') FROM comments WHERE comments.author_user_id = '1') The subquery alone yields "post" (`comments.category` is an ENUM() field); and I want to select all the rows from the "posts" database table. Ideally, the query would be processed like: SELECT * FROM posts How do I perform a string concatenation during a SELECT query with MySQL?
SELECT * FROM (SELECT CONCAT(comments.category,'s') FROM comments WHERE comments.author_user_id = '1') The subquery alone yields "post" (`comments.category` is an ENUM() field); and I want to select all the rows from the "posts" database table. Ideally, the query would be processed like: SELECT * FROM posts How do I perform a string concatenation during a SELECT query?
I would like to do an update on a table as below. But i get the error : ERROR: ILLEGAL SYMBOL ",". SOME SYMBOLS THAT...I think i could fix this by putting the subquery into the 'WHERE' clause...but that would mean 4 subqueries: one for each criteria.Is there a easier way to do this ?Thanks!<code>UPDATE NOTICES C, (SELECT COUNT (*) AS NUM, A.Notice_ID ,A.Notice_ClientFROM NOTICES A WHERE 1=1 AND A.Notice_Client IN (15) AND A.Notice_Expire_Time > CURRENT TIMESTAMP AND A.Notice_Create_Time > '2009-10-13-00.00.00.000000' GROUP BY A.RSK_ASMT_TRK_ID, A.RSK_IND_ID ORDER BY NUM D
Is it possible to transform subqueries in WHERE clasue to joins? I can do it for some class of subqueries but have difficulties, e.g., when there is an aggregation in a subquery. Are there any general procedures to make such a conversion? Thanks in advance for any answers. Piotr Synak Infobright Inc.
Is it possible to place a Subquery (results) into an Array? I still haven't figured out the correct Subquery syntax, but I'm trying to select 10 items from "store" and for each item, generate list of possible product_name matches in "master"; SELECT * FROM store LIMIT 0, 10 SELECT * FROM master, store WHERE store.product_name REGEXP UPPER(CONCAT('[[:<:]](', REPLACE(master.product_name, ' ', '|'), ')[[:>:]]')) Can I join the two selects, limit the first to 10 and get the subquery (the second select) into a results array? Should the latter select be the other way around
Although I am not a newbie, I did not see a forum for help postings. I have a complicated subquery that will not work. The actual subquery works fine on its own, but the entire query will not work. I am using MySQL 4.0.25 on a host server and cannot upgrade my database to a newer version. Here are part of the table definitions: Tours tour_id int(2) PK tour_desc varchar(255) amt decimal(10,2) reg_payment reg_id int(5) PK cid varchar(7) FK reg_dt date trans_id varchar(17) Name_badges name_id int(5) PK cid varchar(7) FK last_name varchar(255) first_name varchar(255) Tour_regis tour_reg_id int(10)
I have a query that I've been able to do in T-Sql using an 'in' predicate in a Case/When. I modified this to run in SQL/400 by the error is get is:Quote: Simple comparison operators other than equal and not equal cannot be used with a list of items. ANY, ALL, and SOME comparison operators must be followed by a fullselect, rather than an expression or a list of items, and cannot be specified in a JOIN condition or in a CASE expression SELECT CLIENT, MACTNM, CLMSEQ, CHKDAY, CASE WHEN CHKDAY = 0 THEN NULL WHEN CHKDAY IN (SELECT BADVAL FROM BADDATES WHERE RTRIM(TBL_SRC) = 'X' AND RTRIM(COL_SRC) =
I think that there may be a problem with subqueries. On an AIX platform running 5.0.19 using the innodb storage engine, explain states that every subquery is dependent, and won't use any indexes, it seems, other than the primary key. Simple cases (made up for test, where I can convert between joins and subqueries easily) show the joins selecting and using the "proper" indexes, but the subqueries always use PRIMARY key on the nested query and declare it to be dependent. These test queries are of the form: select X from A where A.B_id in (select id from B where B.c1 = "whatever
so i was wondering if there's anyone who can help me sort something out. i have an SQL query that should show the details of a person (a search feature) that has a subquery inside an Inner Join, and the subquery is a Select statement.Currently there's no problem with the sql query, but when i test the query as db2 i have this error: An ON clause associated with a JOIN operator or in a MERGE statement is not valid.. SQLCODE=-338, SQLSTATE=42972, DRIVER=4.11.69So, I'm asking, are there some ways to rewrite the query without having to use a subquery within the join statement?I'm using DB2 For Lin
Greetings, I have the following query. It produces some details for a specific dat ($scandat) and for a specific location ($_GET["dep"]) Select scanarch.*, substr(scanid,6)+0 as sort, c.senddep, c.deliverdep, c.docnum from scanarch s,consignments c where (s.scantype = 'O') and s.scandate = '$scandat' and s.depotscan<>0 and left(s.identifier,22)=c.identifier and c.senddep = ".$_GET["dep"]. " and s.identifier <> '' order by sort"; It's a report of scans (barcodes) which match the criteria of the where clauses. Anyway, an item can be scanned twice wh
subquery not working for mySQL control center0.9.4 beta. The query is syntactically correct and a simple one. Is it a bug in mySQLcc?
Is it possible to optimize a correlated subquery in case of updation.Is there any type of SQL which can replace these type of SQL.My sql is given belowupdate table_A set (A.col1l, A.col12, A.col3) = ((select B.col1l, B.col12, B.col3 from table_B where B.site_id = A.site_id)) ; [Note there is a index on B.site_id]while the table_A has around 71columns & 519385 recordswhile table_B has around 5 columns & 357548 records.The time for updation is around 17 mins.when I created a temporary table of table_A with 4 columns (ie all columns which is used for updation or used in join condition) th
I have a query that works: SELECT obiskovalci.uporabnik as uporabnik, obiskovalci.email as emailobiskovalci, recipes.Name, recipes.datum, recipes.kategorija, recipes.ID, rs.sirina, rs.visina, rs.ime, rs.ID as IDslike, recipes.podkategorija, recepti.clan, MIN(rs.sortiranje) as slika FROM recipes FORCE INDEX (recepti_sort) INNER JOIN obiskovalci ON recipes.clan=obiskovalci.ID LEFT JOIN receptislike rs ON recipes.ID=rs.IDRecept WHERE recipes.datum< now() GROUP BY recipes.datum DESC, recipes.ID DESC LIMIT 0,50 Ok, don't mind exactly how it works, here is in English: I have a table recipes that
am stuck again in need to do a distinct for two fields on the first inner join something like distinct a.urlsite , a.occured how can i do this , do i need to do a subquery SELECT u.name, DATE_FORMAT(a.occured, '%Y-%M-%D'), c.category, count(a.user) AS hits FROM boxlogs.users AS u INNER JOIN boxlogs.urlaccesses AS a ON u.user = a.user AND MONTH(a.occured) = 8 AND YEAR(a.occured) = 2006 INNER JOIN boxlogs.categories AS c ON a.category = c.category WHERE u.name <> 'scritchley' AND u.name <> 'araqib' AND u.name <> 'abasi' AND u.name <> 'nhall' AND u.name <> 'pdenyer'
I get the results I wish from each of these queries. I would like to make the 2 queries one. I have tried subquery and several joins. I can't get seem to fine the correct syntax. SELECT * FROM CourseSchedule, Days WHERE CS_Campus = "Lowell" AND CS_Year = "2007" AND CS_Season = "Spring" AND CS_Week = "8W1" AND Day_dayOfWeek = "Tuesday Friday"; SELECT * FROM qualified q WHERE Qual_Prof_ID = "259BOR"; The goal is to have only classes appear in the result set where the instructor is qualified to teach.
Greetings,I am attempting what I believe to be a very basic operation. I am trying to do a table update using a subquery that contains a join operation.For your information I am running:IBM Informix IDS 11.10 Developer EditionRed Hat Enterprise Linux 4Before writing the SQL statement I consulted the Informix SQL Guide that comes with the installation. The format of the Update statement is:"UPDATE update_table SET update_table_property = (SELECT source_table_property FROM source_table WHERE update_table.compare_property = source_table.compare_property);" I have done this successfully
Hi...not sure where to post this question. Is there any version of MySQL that will support Limits within a subquery? I am using 5.0. I tried to run this query: SELECT Count(b.SessionID) as RecordCount FROM reports.Views c JOIN reports.Sessions b ON c.SessionID = b.SessionID RIGHT JOIN reports.ViewTypes a ON a.ViewTypeID = c.ViewTypeID and start_date >= '2006-09-12' and (b.SessionID in (SELECT SessionID FROM reports.views WHERE views.HeadingID = '199140' LIMIT 1)) GROUP BY a.ViewTypeID But I get the error message: "This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME s