Update problem
I am trying to update a table from results generated from a select query, but can't seem to get the queries running right. The select query works fine, but when I try to use the results for an update it error out. Here is my query: db_connect(); $query = SELECT cst_SiteID FROM customers WHERE cst_Offer = 1; echo $query; echo br/; $result = mysql_query($query); $numofrows = mysql_num_rows($result); $numofcols = mysql_num_fields($result); echo table\n; for ( $r = 0; $r $numofrows; $r++) { $row = mysql_fetch_array($result); echo td$row[0]/td; $updatequery = UPDATE assets . SET asset_Managed = '2' . WHERE asset_SiteID = $row[0]; $result = mysql_query($updatequery) or die (Query Failed: $updatequery); $numofrows = mysql_num_rows($result); for ($i = 0; $i $numofrows; $i++) { $row = mysql_fetch_array($result); echo td$row[0]/td; } } I just want to use the result from the first query as input to my update query. Any ideas what I am doing wrong? Sincerely, Chris Dietzler ATT Enhanced Network Services 858 812 4062 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
MySQL 4.0.2 RPM install on RED HAT Fedora Core 1
I am trying to install the RPM and get a couple of errors saying the libsqlclient.so.10 RPM is missing. I have tried to search for this but cannot find the proper package for it. Any help would be appreciated! Sincerely, Chris Dietzler ATT Enhanced Network Services -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Join question
Running 4.0.18 I am trying to run a query where the query gets the offer_ID of a certain customer from the offer table and displays in the results the offer_Name associated with the offer_ID. Right now the way the query is working it displays all the offers in the offer table regardless of the offer_ID assigned to the customer. Any thoughts? SELECT c.cst_SiteID, c.cst_IDC, a.asset_ID, o.offer_ID, o.offer_Name FROM customers c, assets a , offers o WHERE c.cst_SiteID = a.asset_SiteID AND cst_Name LIKE 'z%' Results: | cst_SiteID | cst_IDC | asset_ID | offer_ID | offer_Name | ++-+--+--++ | 6916 | 2 |18165 |3 | Basic Monitoring | | 6916 | 2 |18165 |8 | Unknown| | 6916 | 2 |18165 |1 | Advanced Managed | | 6916 | 2 |18165 |5 | Mixed Managed | | 6916 | 2 |18165 |6 | No Monitoring | | 6916 | 2 |18165 |2 | Advanced Monitoring| | 6916 | 2 |18165 |4 | Internally Managed | | 6916 | 2 |18165 |7 | Performance Monitoring | ++-+--+--++ customers Table +++--+-+ -+-+---+ | cst_ID | cst_SiteID | cst_Name | cst_IDC | cst_MgtType | cst_POC | cst_Offer | +++--+-+ -+-+---+ | 2418 | 897 | JTE (H.K.) Limited | 9 | 5 | 0 | 6 | | 2417 | 799 | Zape Corporation | 7 | 5 | 0 | 6 | | 2416 | 728 | Zone , Inc. | 9 | 5 | 0 | 6 | | 2415 | 702 | ZL Batavia, LLC | 16 | 1 | 0 | 1 | +++--+-+ -+-+---+ offers Table +--++--- --+ | offer_ID | offer_Name | offer_Search | +--++--- --+ |1 | Advanced Managed | Advanced Managed | |2 | Advanced Monitoring| Advanced Monitoring | |4 | Internally Managed | Internally Managed | |3 | Basic Monitoring | Basic Monitoring | |5 | Mixed Managed | Mixed Managed | |6 | No Monitoring | No Monitoring | |7 | Performance Monitoring | Performance Monitoring, Performance Managed | |8 | Unknown| Unknown | +--++--- --+ Sincerely, Chris Dietzler ATT Enhanced Network Services 858 812 4062 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Pulling a value from a filed in a result to use as another variable
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Pulling a value from a filed in a result to use as another variable
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]