Jump to content

help with select statment


knowram

Recommended Posts

is there a what to do some thing like this

 

$result = mysql_query("select * from Networkinfo where mNum 'is the highest' ") or
				die ("nope1");

 

I am trying to figure out a way to assign an increasing number to each entry that gets added to a table. So my thinking is that i have to know the highest number that is currently in the table and then just add 1. or is there another way?

 

Thanks for the help

Link to comment
Share on other sites

the first table only has 2 fields

right now they are set up like this

 

mNum            varchar(255)

mCompany      varchar(255)

 

i am using phpmyadmin however I am really new to it. I don't know much more then adding adding fields to tables and tables to databases and adding databases. I have been mostly using either varchar or me mediumtext for the field types. And i know nothing about keys yet. however I am a fast learner

Link to comment
Share on other sites

ok now that i have done that let me explain what i am trying to do. I have to tables

 

table 1 (aMember)

 

mNum

mCompany

 

table 2 (aOffice)

 

mNum

oNum

Office

Address

Domain

Net_Connection

 

I have several member company's (mCompany) and each of those has several Offices. if I add a new office to a member company i just add the info to the aOffice table using putting the mNum from the member company entry in the aMember table. no big deal.

 

But if I am adding a new Office that is part of a new member company I want to add the member company name to the aMember table which is now getting a mNum assigned automatically. How do I know what that mNum is so I can use it when adding the office info to the aOffice table?

 

Hope that makes sense.

Link to comment
Share on other sites

thats fine, i generally just make a field called ID as my primary key and auto increment it for any table just for ease of use.  Then i link between tables with my users names.

 

try the function $idnum=mysql_insert_id();

where it will give you the autokey num of the last query of insertion

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.