|
If you have an ID column on the table, you could use the following.
DELETE FROM Table
WHERE ID IN
(
SELECT TOP 20 ID
FROM Table
ORDER BY ID DESC
)
Hogan
|
|
|
|
|
How would this WHERE caluse return no results?
WHERE UniqueID = 'C7B411C6-E17D-454a-9B7B-1A170F33A072'
OR UniqueID != 'C7B411C6-E17D-454a-9B7B-1A170F33A072'
There are items in the IS catalog, if i remove the WHERE clause they are returned. If I do a similar query using Contains() then its fine too.
WHERE Contains(UniqueID,'C7B411C6-E17D-454a-9B7B-1A170F33A072')
Now I don't want to jump the gun and suggest there is something fundimentally wrong here without fully understanding IS and its Sql Query language but equality is pretty basic, it's either equal to or not equal to.
Is this a case where FILE_NOT_FOUND might come in?
(WTF FTW )
Any insight into this wierd behaviour would be great.
Andy
EDIT: Forgot to mention this is on Windows Xp Pro, where UniqueID is a cached VT_LPSTR, 40 length.
(Yes I know I cross posted ... naughty me :P but I'm really not sure usre how much user cross over the OS and Sql forums get )
|
|
|
|
|
I have a sql statement where I am trying to pull all records that have a value as well as those records that do not have a value for a particular attribute in a table. To pull the values that were Null I used the following condition "OR cd.BCAT IS NULL" (where BCAT is the attribute) When adding this condition to my sql statement none of the records that have NULL values are returned. When checking the design of the table in SQL Server, I noticed that whoever set the table up, specified the default value for this particular attribute to '' (which I assume is nothing as opposed to null). Knowing this I changed the condition to "OR cd.BCAT IS ''". However, when doing this it seems like the query takes for ever, does not return anything, and basically hangs up. Is there a difference between NULL and ''. If so how can I return records that have '' as the value? Thanks in advance to all that reply.
|
|
|
|
|
NULL is the absence of a value. '' is a value - an empty string. Basically, if you have something which does not have a valid value, e.g. an optional date, you would normally use a nullable column. This means that you don't have to store a "magic" value to identify these values.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks Pete. Making the column's default value NULL should make my sql statement work. However, w/o jeopardizing the integrity of the database (i.e. relationships, data), I am assuming that making this change will only affect the values in this table (and not update other tables where this value may be referenced). Secondly will I need to do an update on existing records such that they now incorporate the NULL value or will making this change apply it to existing records? Is there absolutely any way to check for ''? (if not I will try the suggested) Thanks, again.
|
|
|
|
|
Alternatively you could just add WHERE (column IS NULL or column = '') to your query. It's not pretty, but it would work.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Or WHERE IsNull(column, '') = ''
|
|
|
|
|
dboy221 wrote: "OR cd.BCAT IS ''".
Perhaps you mean OR cd.BCAT = '' ?
|
|
|
|
|
my boss sent me this, I dont know how to do any kinda SQL
Hey Danny, can you make a data entry form so Jane can type customers' email addresses into our database? It needs to have two fields: store number and email address, and a submit button that inserts into sutherlands_mailing_list. Can you save it as www.webice.net/addresses.asp
and the second email she sent
Either way - you're connecting to a table on the SQL server, which is called sutherlands_mailing_list, not an access database. Look at the data entry pages on www.sutherlandshomedesigncenter.com/manager to see how to connect. Your connection string is already built if you use the file include 'database_connect' - you basically just have to write a simple SQL INSERT statement.
can anyone help me with this?
|
|
|
|
|
Does your boss know you do not know SQL? If so you should ask for time to study SQL, especially if you will be in charge of the upkeep of this. If you gave your boss the impression you do know SQL and really don't all I can say is you dug your own hole.
Also it looks like you posted about this in another forum (ASP). Please do not crosspost.
______________________
stuff + cats = awesome
|
|
|
|
|
sorry about the cross post, and i did not tell her that i knew it or hinted at it. I will have a talk i guess
|
|
|
|
|
United States law says that (as long as you did not claim at some point you did know) if you do not know how to do something that is part of your job, the company is required to give you the necessary time and resources (book, class, etc) for you to learn the process in a reasonable amount of time on the company dollar.
______________________
stuff + cats = awesome
|
|
|
|
|
hi all
sir i have made a database and a table and add data in tables in mysql
but then i reinstall another version of mysql .
now i cut the data folder from older version and paste it
into newer version
now when i use show databases in newer version of mysql
it will show that database and tables also
but when i try to show values in tables it will give an error that this table
does not exists
please sir
thanks
hi
|
|
|
|
|
You've already posted this question - just below in fact. Please don't repost.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: You've already posted this question - just below in fact. Please don't repost
Actually, the post below was orginally asking if it was okay to post a question on MySQL in this forum. When I replied that it was okay he then changed the content of the post to the question he wanted to ask.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Hmmmm. Oh well - still breaching the "rules" though.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
paras_s12 wrote: can i ask a query related to mysql please in this section
Yes
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
I should add that unless your question relates to the way MySQL interacts with .NET applications you may find the responses limited. If it is a purely MySQL question then a forum that deals with that would more likely be useful to you. People will still be able to help you, there are just less of them specialised in that technology here.
Welcome anyway.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Assume that I have a table with UserName and Password columns. Both are varchar type. I given primary key for UserName. But we got another requirement that Password also should not repeat. So I tried setting primary key for Password also. But my first attempt resulted in failure. SQL said you can't create multiple primary keys on a table. Is there a concept called composite key ? Is it related to my requirement ? Or is there any other way to make both fields to be acted like primary key (Both fields should not repeat).?
|
|
|
|
|
You can mark a column as UNIQUE which ensures its value doesn't repeat. However, I don't believe that fits your requirements.
What if two independent users happen, by chance, to pick the same password? What if one of them is mallicious? The fact the second user cannot choose their password means they know someone else already has that password. Now their brute force attack on the system is faster because they have a known password and just have to match it to an existing user.
Most systems don't allow a user to duplicate a password they've used in the past. I would guess that it your requirement. In which case you need to store a history of passwords for each user.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Colin Angus Mackay wrote: What if two independent users happen, by chance, to pick the same password?
Thanks, But this is not the real scenario. I just given a simple example about my requirement. I am using this in another table. Not using for users. Any other way to ensure both of the fields won't repeat ?
|
|
|
|
|
What he told you to do, solves the problem. He was just telling you why not to do it with passwords.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Navaneeth. wrote: Thanks, But this is not the real scenario
Why not tell us the real scenario? It would have mean I didn't have to write all those warnings about security which are, only now, obviously not needed.
Sometimes I really wonder whether I'm wasting my time helping here or not.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Real scenario is, I store ItemCode and ItemName in one table. ItemCode is primary key. I don't want to repeat ItemName also. For that I tried this. Actually I just given a example about username and password to understand the problem easily. But I think I am mistaken and my first example made lot of confusion. Sorry.
Colin Angus Mackay wrote: Sometimes I really wonder whether I'm wasting my time helping here or not.
Never. Your postings are excellent. You are doing good job. Thanks
|
|
|
|