Jump to content
mattl

**SQL NOOB** SQL Question

Recommended Posts

Hello All, first off big thanks to all who have contributed to this awesome forum. I have found many useful plugins, tabs, etc... from here.

 

Now to my question(Prefaced by the statement I am a SQL Noob) - Can someone help me find my error in the following SQL Query?

 

SELECT DISTINCT v_networkadapters.ComputerID, AdapterName, IPAddress, Gateway, NetMask, Description, Status, DeviceType, Computers.ComputerIP, Computers.DNSInfo as 'DNS' FROM v_networkadapters, Computers WHERE v_networkadapters.ComputerID=computers.ComputerID AND v_networkadapters.ComputerID=%computerid%

 

Thanks for any help anyone can provide!!

Share this post


Link to post
Share on other sites

Hello Matt,

 

I've found 2 issue - first is that ComputerIP is not actually a column in Computers. Second, you need to have a JOIN statement in there. Here's the query I wrote, with the two issues I mention

 

SELECT DISTINCT v.computerid, v.adaptername, v.ipaddress, v.gateway, v.netmask, v.description, v.status, v.devicetype, c.dnsinfo AS 'dns' FROM v_networkadapters v JOIN computers c ON v.computerid = c.computerid;

 

Now, that gets you the entirety of network adapters list. I see that you have a comparison to a current machine - what is it that you're trying to do?

 

Mind you, I'm relatively new to joins, and SQL definitely isn't my strong point, but I ran this query and it didn't break my server, so it may work for you too...

Share this post


Link to post
Share on other sites

Just remember that TRUNCATE, DROP, DELETE, REPLACE, and INSERT could mess your day up :). SELECT is your friend, and welcome to the forum @mattl.

Share this post


Link to post
Share on other sites

I'm building a custom tab to show network info for a specific computer, and then I have scripts built already to manipulate the network Info. The query you posted works, bringing in all computers.

 

I was able to add a WHERE clause to the end to pull in only the current computer stats.

 

THANKS GUYS for the quick response. Now to get accepted into the Geek Exchange. :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×