473,661 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MSSQL SELECT error

1 New Member
I've the following Select Statement that generates errors, could someone tells me why? :(

SELECT TOP 20 * FROM tickets WHERE ticket_ID NOT IN (SELECT TOP 20 * FROM tickets ORDER BY ticket_ID DESC) ORDER BY ticket_ID DESC;

Warning: mssql_query() [function.mssql-query]: message: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. (severity 16) in c:\Inetpub\wwwr oot\schoolProje ct\admin\show.p hp on line 437
Aug 17 '05 #1
1 8539
haggul
7 New Member
Try this ??

SELECT TOP 20 * FROM tickets WHERE ticket_ID NOT IN (SELECT TOP 20 ticket_ID FROM tickets ORDER BY ticket_ID DESC) ORDER BY ticket_ID DESC

You had it checking the id against all columns - take it you are trying to get the 21st to 40th most recent??
Aug 19 '05 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5451
by: Guillaume | last post by:
Hello, I have a strange problem while using mssql server driver: when i update/insert in/delete a table and want to redirect after, i have the following error message: CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: The strange thing is that if i do a select or use mysql driver (with select,
9
7255
by: Darren | last post by:
Hi wondering if anyone can help. What i'm trying to do is get a company from a MSSQL database with the COMPANYNO which is a 'uniqueidentifier'. Then with this COMPANYNO I want to reference it to another table (on same database) to extract more details. When I get the company name and company no the company no outputs like... 63180001000000000000000000000000 In basic terms I'm only getting it like... $query = "SELECT COMPANYNO FROM...
7
23868
by: mj | last post by:
Hello, thanks for the help. I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm firewall) Apache 2.0.52 MySQL 4.1.7 PHP 5.1.0-dev I have developed a PHP/MySQL web app that tracks jobs for me, and we
1
7029
by: Philip Mette | last post by:
I am in a crunch and need to covert this Oracle statement to MSSQL. Is there any Oracle/MSSQL experts out there that can help me? I do not understand the syntax enough to modify this. Thanks so much for any assistance. Here is the procedure. CREATE PROCEDURE UPD_ACTIVITY IS CURSOR ACT_cur1 IS SELECT DISTINCT A.ACCT_NUM, A.DUE_DATE
5
1615
by: Markon | last post by:
Hello I have recently decided to upgrade my programs to enable users to have mssql databases instead of access. I have since then run into many incompatibilities between their sql: access has IIF(x>y,a,b) whereas mssql hase case when (this already means hundreds of changes in queries) it does not have format(number,'#,##0.00') or format(date,'dd.MM.yyyy') but most surprising is following: access allows this while mssql reports error...
1
1907
by: brosner | last post by:
I installed MSSQL 2000 on my desktop (running NT 2000). No problem. I created an adp and attached it to a database within MSSQL 2000, no problem. When I go into MS Access, on another PC (running Windows XP Pro) on the same network, and try to create a using 'Project(Existing Data)' and connect it to MSSQL 2000 on my desktop, I fill in the Data Link Properties '1. Select or enter server name', no problem, '2. I click on Use Windows NT...
14
2920
by: guswebb | last post by:
Hi. I'm a newbie to PHP and am having a few problems as follows... I have installed PHP successfully on server 1 which is running IIS 6 (W2k3) and hosting multiple sites, some of which connect to MSSQL 2k (SP4) on server 2 (using ASP). I can load a basic 'Hellow world' PHP page hosted on server1 but when I add the code to create a simple connection to MSSQL on server 2, my PHP doesn't seem to connect nor output any of the desired query...
4
3302
by: sujiforsql | last post by:
i have a stored procedure like below CREATE PROCEDURE display_Products @CategoryID int AS BEGIN DECLARE @authors_cursor CURSOR SET @authors_cursor =CURSOR FAST_FORWARD FOR SELECT TOP 10 COUNT(iProductFK) AS s ,iProductFK FROM tblOrderDetail WHERE iProductFK IN(SELECT iProductFK FROM tblCategoryProduct WHERE iCategoryFK = @CategoryID) GROUP BY iProductFK
3
2106
by: tiptap | last post by:
Hey, I have a really confusing problem here. I'm using MSSQL & PHP. I have created a querry in MSSQL that basically shows a list of events and shows them in date order. I have written a bit of code into the mssql statement that says 'If the current date is the friday before the event date, and the event date is on a saturday or sunday, then dont show that event' when I run that code in mssql it returns the correct results - when its firday...
6
6320
by: kayox007 | last post by:
hi everyone, i tried using the code below to connect to my database (MSSQL) but it gave me the error benith. actually am new to php and i dont want to use mysql because am used to MSSQL thanks code <?php $con = mssql_connect('OLUKAYODE\SQLEXPRESS', 'sa', 'admin'); mssql_select_db('image', $com); $sql = "select * from main"; $get = mssql_query($sql, $com);
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.