Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't query index??!?

Status
Not open for further replies.

rrsub

MIS
Oct 23, 2002
536
US
I have a field which is the key for the table. Why can't I use that value as a lookup? Do I have to duplicate it?

If so, why can't I autoincrement it?
 
"the key for the table" is vague. Do you mean the primary key?

What do you mean by "use it as a lookup"?

What SQL statement did you use to create your table?

What SQL statements are you failing to do what you want to do?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
This is back to my last issue but then I figured out that I can't compare the value from a primary key to a value in another table.

In table 1, there is a value of 3 in one field

I want to be able to lookup row 3 in table 2 and fetch all that information.

I originally thought that WHERE index = 3 would work but it doesn't. For that to work, I would have to create another field but that field won't be able to auto increment.

I figure that if I could fetch the row number, that would be the same. I'm reading up on mysql_fetch_row right now.
 
But you an compare the value from a primary key to a value in another table. In terms of relating tables in a SELECT statement, an autoincrenting primary key is just an integer column type.

That's why I'm asking so many questions.

It seems to me you've made some false assumptions about the source of your issue.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I used MySQL CC v.93 to create the tables

The statement I'm using is

SELECT server FROM name_servers WHERE index = '3'

If I use

SELECT server FROM name_servers WHERE ip_address = 'x.x.x.x'

I get a value returned

 
Here's my query

select server from name_servers where index = 3

ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'index = 3' at line 1

Used the quotes because when I queried the IP address, that's the only way I could get a value.
 
Thanks bunches!!!!!!!!

:)


I've been on this off and on for about 6 weeks now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top