Link to home
Create AccountLog in
Avatar of tim_carter
tim_carter

asked on

SELECT IN??

Hi guys

i have a table called tracker with alot of records, on each record there is a iplong field which contain a number that i need to lookup data for in another table and then join some fields from that table to the first table. how do i do that?

something like this?


select
countryshort
from
ipcityisp,
tracker
where
tracker.iplong in (select countryshort from ipcityisp where tracker.iplong between ipfrom and ipto)

the tracker.iplong is a FLOAT and so is IPFROM and IPTO but it just tells me

Error converting data type nvarchar to float.


is this not the right way to do that?
Avatar of Jinesh Kamdar
Jinesh Kamdar
Flag of India image

Try this.

SELECT countryshort
FROM tracker
WHERE countryshort IN
(SELECT countryshort FROM ipcityisp WHERE T.iplong BETWEEN ipfrom AND ipto);
hi, try this

select
countryshort
from
ipcityisp INNER JOIN tracker ON tracker.iplong between ipfrom and ipto
how exactly do ipcityisp and tracker relate to each other? what is the FK the connects the 2 tables?

right now, you're trying to compare tracker.iplong and ipcityisp.countryshort (which presumably is a nvarchar), which is why you're getting the error.
ASKER CERTIFIED SOLUTION
Avatar of Jinesh Kamdar
Jinesh Kamdar
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer