I think you need a join. You didn't provide much info about the second table, so I'll pretend it's named assets with columns named host, ip, and cst_SiteID. Something like

  SELECT c.cst_Name, c.cst_SiteID, a.host, a.ip
  FROM customers c, assets a
  WHERE c.cst_SiteID = a.cst_SiteID
  AND cst_Name LIKE '$_SESSION[Name]%';

should do the trick. Of course, you'll have to replace the assets table and column names with your real values.

Michael

Chris Dietzler wrote:

Actually, cst_SiteID is tied to assets owned by the customer in another
table. What I need to do is get the cst_SiteID and use it to get a list of
assets from the other table. I have created a successful search page for an
individual site id search, but now want to do a search by name, where
multiple sites are displayed. Here is my current query:

mysql_select_db(mig) or die("Problem selecting database");
 $query = "SELECT * FROM customers WHERE cst_Name LIKE '$_SESSION[Name]%'";
 $result = mysql_query($query) or die ("Query failed");
 //let's get the number of rows in our result so we can use it in a for loop




Search by Site ID SiteID: 7820 <-- Search for SiteID 7820 + Center Technologies, Inc. 7820 <-- Results from Search listing Name and Site ID

+ 37670 7820-www-db0 63.240.145.18  7820        <-- Assests Associated with
SiteID 7820






+ -----Original Message----- From: gerald_clark [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 02, 2004 11:59 AM To: Chris Dietzler Cc: Mysql (E-mail) Subject: Re: Pulling a value from a filed in a result to use as another variable




Chris Dietzler wrote:


I am trying to pull cst_SiteID from a query result to use in another query:

SELECT cst_Name,cst_SiteID FROM customers WHERE cst_Name LIKE 'st%'

+------------------------------------------+------------+
| cst_Name                                 | cst_SiteID |
+------------------------------------------+------------+
| Stanley Associates                       |       8182 |
| Starbucks Coffee Holdings                |       9261 |
| State Farm Mutual Automobile Insurance C |       9523 |
| State of New York -NYMTC                 |       7356 |
| State Street Bank and Trust Company      |       8305 |
| Staubach Company                         |       8240 |
| Staveley Services                        |       8502 |
| Stellar Internet Monitoring, LLC         |       8665 |
| Stonewall Kitchens                       |       8221 |
| Strategic de Mexico                      |       4401 |
+------------------------------------------+------------+

Can anyone help me figure out how to assign a new variable to the

cst_SiteID

for each row?
Sincerely,
Chris Dietzler





Well, if cst_SiteID is autoincrement, try: update customers set cst_SiteID=0 where cst_Name LIKE 'st%';






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to