|
I think this is pretty easy, unless I don't understand what you want to do.
Wouldn't this work?
select * from property
where Extension = 2 And Num_Key = '0196' and
Cast(Substring(Attrib_code,5,5) as bigint) between 00274 And 01189
Hope that helps.
Ben
|
|
|
|
|
Yes man the code works but i want it to depent on two fileds for its results "Extension" and "Num_Key".
it must display between 00274 and 01189 but based on the Extensions and Num_keys
help me man
thanks
Vuyiswa
|
|
|
|
|
I guess I don't understand then. All three of those things are in the where clause. First you limit the result set by Extension and Num_key, then you limit it by display between 00274 and 01189. I am pretty sure the query I gave does what you are asking. It is doesn't please try to explain what you want again.
Ben
|
|
|
|
|
Thanks Ben for your reply and patience. the code is correct it does not return an error but it return an Empty table.
i tested
select * from property
where Extension = 2 And Num_Key = '0196' separately and it returned 1239 Rows. but when i combine it with the code you gave me
select * from property
where Extension = 2 And Num_Key = '0196' and
Cast(Substring(Attrib_code,5,5) as bigint) between 00274 And 01189
it shows an Empty table by only displaying the Column names only
Please help man
thanks
Vuyiswa
|
|
|
|
|
Well, then my guess would be in those 1239 rows there aren't any that have a value between 274 and 1189.
Try this
select * from property
where Extension = 2 And Num_Key = '0196'
order by attrib_code
That way you should be able to see if you have any between 274 and 1189
Hope that helps.
Ben
|
|
|
|
|
Thanks man when i run it it gives me 1329 records.
Vuyiswa
|
|
|
|
|
i mean the code you just gave me
select * from property
where Extension = 2 And Num_Key = '0196'
order by attrib_code
Vuyiswa
|
|
|
|
|
So the question is in those rows that are returned look at the attrib_code and tell me if you see any in the range you are looking for. I am guessing that you will not find any in the range you said you wanted.
Ben
|
|
|
|
|
Thanks man for your reply,i have used the wrong column, i should have used Lis_key, and i used Attrib_key, so when i enter that range its good its showing results. thanks man you are a star . my mistake for the wrong column. i saw your profile, i just uploaded my photo. am 25 turning 26 in September this year thanks man.
kind regards
Vuyiswa
Vuyiswa
|
|
|
|
|
i mean the code you just gave me
select * from property
where Extension = 2 And Num_Key = '0196'
order by attrib_code
Vuyiswa
Vuyiswa
|
|
|
|
|
Thank you man , my mistake it wasnt Attribute code column it was supposed to be Lis_Key. remember yesterday we did the Attribute code, thanks a lot man for you time, i will rate you as my mentor
kind regards
Vuyiswa
Vuyiswa
|
|
|
|
|
Hello
VS 2005
I am using typed dataset in my vb project.
In my window the user will insert a new customer
TA_Customer.insert(,,,,,,,)
but if they change their mind and decide they don't want to insert a new one. Is it possible to roll back the changes.
The customer wants be able to add a new customer, then if they change their mind, click close on the window and not commit the changes.
Many thanks for any ideas or code,
Steve
|
|
|
|
|
I think the best you can do is to allow them to delete a new customer. I don't think you want to hold open any transactions on a customer table.
Ben
|
|
|
|
|
Hello,
Thanks for your reply.
I was thinking of holding the data in the memory of the typed dataset then clearing this if they decided to close the form.
Any ideas about the above.
Steve
|
|
|
|
|
In the dataset there is something called AcceptChanges(). You have to call this for any changed to be accepted. The problem is without doing this I am not sure that the data will show up anywhere. I guess, if you are just planning on having data in memory you can do that, but things can get pretty bad if you start assigning id's. You can start to run into situations where two people have the app open and both create a new customer, both get assigned the same id. Now you have a problem.
Ben
|
|
|
|
|
<br />
SELECT [DrawID],<br />
COALESCE(CA.[ForeName], 'Not drawn') As Winner,<br />
FROM Draws D<br />
INNER JOIN CompetitionA CA<br />
ON D.WinnerA = CA.CompAID<br />
WHERE CompID = @CompID<br />
ORDER BY DrawnOn ASC;<br />
I am using the following code as above. It does work but not properly. There are three rows that I would like to return from the database but I only get one. I know the reason for this is because only one of them has been given a 'D.WinnerA' value. The other rows will get this value in time but at the moment they do not have it. Therefore the line:
<br />
INNER JOIN CompetitionA CA<br />
ON D.WinnerA = CA.CompAID<br />
is ruling two of the three required rows out. What is the best approach to this problem?
Thanks in advance
|
|
|
|
|
Change the INNER JOIN to a LEFT JOIN .
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Great thanks for that. Iv'e neaver really fully understood the other JOIN methods. What is the exact reason for using LEFT JOIN? Strictly for this reason?
Thanks
|
|
|
|
|
It is. Basically they work like this (assuming that you have two tables A and B):
SELECT * FROM A
INNER JOIN B
ON A.ID = B.FKID This returns records where there is a match in both A and B.
SELECT * FROM A
LEFT JOIN B
ON A.ID = B.FKID This returns ALL records from A regardless of whether or not there is a matching record in B. Similarly, RIGHT JOIN returns all records from B regardless as to whether or not there is a matching entry in A.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Oh i see. That makes alot of sense i guess. Thanks for that
|
|
|
|
|
|
I should have realised that you would have a summary somewhere. Nice one.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Am now Searching certain range in a character string Attrib_Code,
which has more Characters Example 019600197/1/R.PV000000. i have more than 50 thousand recards with the same First Four numbers. they differ from "00197", the other parts are not important for me. i want to search a range from "000197" till "000274", how do i search the rages in strng? inside substring.?
Vuyiswa
|
|
|
|
|
try this
SELECT * FROM tblA
WHERE cast(substring(Attrib_Code, 5, 5) as bigint) between 197 and 274
Regards
KP
|
|
|
|
|
select * from property
where Cast(Substring(Attrib_code,5,5) as bigint)
between 00274 And 01189 Man the Code works thanks man, i forgort to ask you something again, the is a Column , i need to Extract those who are in Extension 6, i tried extent the query but i get a lot of errors, your experience will help.
Thanks man
Vuyiswa
|
|
|
|