Click here to Skip to main content
15,886,110 members
Home / Discussions / Database
   

Database

 
AnswerRe: How to get the Table Name and Total Row Numbers? Pin
mr_lasseter4-Mar-07 11:11
mr_lasseter4-Mar-07 11:11 
Questionscript DB Pin
Mridang Agarwalla4-Mar-07 4:06
Mridang Agarwalla4-Mar-07 4:06 
AnswerRe: script DB Pin
Harini N K4-Mar-07 19:24
Harini N K4-Mar-07 19:24 
QuestionRemote Server Pin
alexrad4-Mar-07 3:11
alexrad4-Mar-07 3:11 
AnswerRe: Remote Server Pin
Hesham Amin4-Mar-07 4:05
Hesham Amin4-Mar-07 4:05 
AnswerRe: Remote Server Pin
Krish - KP4-Mar-07 21:40
Krish - KP4-Mar-07 21:40 
GeneralRe: Remote Server Pin
alexrad5-Mar-07 1:29
alexrad5-Mar-07 1:29 
QuestionNeed help with tailoring a big sql statement Pin
MasterShin3-Mar-07 11:52
MasterShin3-Mar-07 11:52 
Hi,

I have three tables with two relations.

First table is users, which just stores userids (autonumber), and a lastseen (text).
Second table is Names. Every user has names, right? So it's just rows of userid(long)/name(text).
Third table is IPs. Every user has a few ips, right? So again, it's just userid/ip.

The relations are just the ones I mentioned, a user has names and ips.

I have a name and an ip. I want to select a union from the IPs and Names.
The union needs to have only users that have the ip given in their ips, or - here's a tricky part - have an ip with first two octets the same as the given ip but also the name must appear in the user's names.

The idea is that given a name and ip, I want to select all previously entered users who are probably the same user.
But, after finding all these users, I also want to merge everything that I found to just one user. So all the ips I found should be updated to relate to the first user found, and the same for the names.

Any ideas?

I tried this: (given name is MasterShin and given ip is 204.15.0.0)

SELECT Players.userid, Names.name as [value], 1 as [type] FROM (Players RIGHT OUTER JOIN [Names] ON Players.userid = Names.userid) LEFT OUTER JOIN IPs ON Players.userid = IPs.userid
WHERE IPs.ip = '204.15.0.0' OR (IPs.ip LIKE '204.15.*' AND Names.name = 'MasterShin')
UNION
SELECT Players.userid, IPs.ip as [value], 2 as [type] FROM (Players RIGHT OUTER JOIN IPs ON Players.userid = IPs.userid) LEFT OUTER JOIN Names ON Players.userid = Names.userid
WHERE IPs.ip = '204.15.0.0' OR (IPs.ip LIKE '204.15.*' AND Names.name = 'MasterShin')

And after the select I can go over everything, save on the side what updates need to be done, and later do them.
But this big statement seems repetitive and not efficient...
AnswerRe: Need help with tailoring a big sql statement Pin
WoutL3-Mar-07 12:07
WoutL3-Mar-07 12:07 
GeneralRe: Need help with tailoring a big sql statement Pin
MasterShin3-Mar-07 20:50
MasterShin3-Mar-07 20:50 
GeneralRe: Need help with tailoring a big sql statement Pin
WoutL3-Mar-07 22:40
WoutL3-Mar-07 22:40 
QuestionHow should I deal with a table holding my time as Hour, Minute, and Second? Pin
Khoramdin3-Mar-07 5:57
Khoramdin3-Mar-07 5:57 
AnswerRe: How should I deal with a table holding my time as Hour, Minute, and Second? Pin
Hesham Amin3-Mar-07 11:48
Hesham Amin3-Mar-07 11:48 
AnswerRe: How should I deal with a table holding my time as Hour, Minute, and Second? Pin
alexrad4-Mar-07 4:32
alexrad4-Mar-07 4:32 
QuestionSQL COMMAND NOT WORKING Pin
govindkedia3-Mar-07 4:22
govindkedia3-Mar-07 4:22 
AnswerRe: SQL COMMAND NOT WORKING Pin
Hesham Amin3-Mar-07 11:55
Hesham Amin3-Mar-07 11:55 
QuestionHow to find no of slot empty of rack Pin
mohd imran abdul aziz2-Mar-07 23:14
mohd imran abdul aziz2-Mar-07 23:14 
QuestionRe: How to find no of slot empty of rack Pin
Hesham Amin3-Mar-07 3:02
Hesham Amin3-Mar-07 3:02 
QuestionWhat is N' ? Whats it use Pin
Ankur.Bakliwal2-Mar-07 19:47
Ankur.Bakliwal2-Mar-07 19:47 
AnswerRe: What is N' ? Whats it use Pin
Hesham Amin2-Mar-07 22:31
Hesham Amin2-Mar-07 22:31 
GeneralRe: What is N' ? Whats it use Pin
Ankur.Bakliwal2-Mar-07 22:33
Ankur.Bakliwal2-Mar-07 22:33 
Questionsql server user authentication Pin
rrrriiizz2-Mar-07 17:36
rrrriiizz2-Mar-07 17:36 
AnswerRe: sql server user authentication Pin
Krish - KP2-Mar-07 19:45
Krish - KP2-Mar-07 19:45 
GeneralRe: sql server user authentication Pin
rrrriiizz3-Mar-07 0:06
rrrriiizz3-Mar-07 0:06 
GeneralRe: sql server user authentication Pin
Krish - KP4-Mar-07 20:37
Krish - KP4-Mar-07 20:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.