SQL Update Command Not Working
I need to update the price in one table from a field in another.
2 Tables named:
newpricelist
pricelist
I have 3 common fields in both, item, description and price. I need to match the item field and take the price from "newpricelist" table and update the price field in the "pricelist" table.
Here is my syntax (it says it will only update 1 record):
UPDATE PRICELIST INNER JOIN NEWPRICELIST ON NEWPRICELIST.ITEM = PRICELIST.ITEM SET PRICELIST.PRICE = NEWPRICELIST.PRICE;
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
UPDATE Not Working.
The page that sends information to the following page has a series of text inputs. The name of the input corresponds to the name of the column in the in the mysql table. There's also a hidden input, "id", that supplies the unique id number of the entry. My script to enter data into the table and to view the table work fine. The update script runs without any errors, but doesn't alter any values. I also tried printing the value of $query and everything appears to be fine. Anyone know why this is happening? Code:
Update Field Isn't Working?
I've created a MySQL database that has one table, that table has two fields, the table is called system, the fields are called status and message. The database is used to populate a html table on a page, that works fine. What I need to do though is have a form on a separate page (which i'm going to add http authentication to) with a simply form consisting of a text box, three radio buttons, and the usualy submit and reset buttons. I need to be able to update the database using this simple form. However this isn't for adding new records, it is purely for editing the existing record as it's to edit simple warning messages to display to the visitors when there is a problem with one of the systems. The radio buttons determine which light image is displayed (green, orange, red) and the text box for the short message. However no matter what i try it just in't updating the fields in the database, the following is the html and PHP i'm using: Code:
Update Statement Not Working
Why does this simple update statement not work with a mysql version 3.23.49, it does work when using 4.0.24..... ? UPDATE listitem,vjbase,list SET listitem.showsec = 7 WHERE listitem.id_vjbase = vjbase.vjbase_id AND listitem.id_vjbase = 3 AND vjbase.id_viduser = 61000 AND listitem.id_list = list.list_id AND listitem.id_list = 1 AND list.id_viduser = 61000
Simple Update Just Not Working /banghead
Background: I've been around the web for quite some time, but am new to PHP/MySQL. I recently purchased a zip code database for an upcoming project I'm starting here, and for some reason the CSV format turned all the zipcodes that start with a zero into 4 digits. No biggie, after hours of wrestling with cpanel MySQL import, then giving up and moving on to modifying the bigdump script I FINALLY got the import done. Now I'm trying to correct the 4 digit zip codes back into 5 digit ones. Table name is ZipCodes, column name is ZipCode (is varchar(5) column). Here's the code I'm trying to use to update things, but it just does not perform the update for some reason. update ZipCodes set ZipCode = Ɔ' + ZipCode where char_length(ZipCode) = 4; I've spent a few hours now reading up trying to figure out what the hell I'm doing wrong, but to no avail. I'm sure the fact that I'm a newb at MySQL isn't helping, but is it something obvious that I'm just to dumb to see at this point?
Update Not Working Within A Stored Procedure
The following query works, but not within a stored procedure, any tips? update ATable,BTable set ATable.lbl= BTable.lbl, ATable.Status = "0", ATable.Code = BTable.code where (ATable.ID = BTable.Tapelbl)
UPDATE Command
I am having bother with a command to update a record from with in a Visual Studio 2005 GridView control. If anyone can help it'd be great! I have an ASP.Net page where the user can edit records from the database, via a GridView. I have managed to connect to the database table (somehow!) using a SQLDatasource control, which works perfectly, but when you go to update a record, you type the changes, click 'Update' and they havn't made it across. The SQL I use is - UPDATE tblRecord SET Announcement=@Announcement, Expiry=@Expiry, Page=@Page WHERE tblRecordID = @tblRecordID When run in a web browser, the code doesn't return an error, just returns back to the page with un-edited records.
MySQL ''UPDATE'' Command...
I am new to fairly new to MySQL and I would like to have some help... I use MySQL database to store all of my user accounts and logins. I need to update all of the data in there automatically without having to do all 10,000 entries manually. My account database has the following tables:
Error On UPDATE Command
on this statemet: UPDATE semaphoreTable SET semaphore = CONTROL_NONE i get this error: Unknown column 'CONTROL_NONE' in 'field list'" it is indeed true that there is no column named CONTROL_NONE. i am trying to set the data in semaphore to CONTROL_NONE semaphoreTable consists of one field, called semaphore, a varchar(50)
CASE Statement In Update Command
I'm trying to update one table (tbl_usage) based on information from another table (tbl_subscriptions) joined by the userID. The usage table tracks the number of times a user hits a page, and decrements the count each time. When the user has a zero count, they are redirected to a warning page. Each week the count is reset depending on what type of license they have (licenseType) and how many of those licenses they've bought (numLicenses). A group license (G) gives them 100 hits, and an individual license (I) gives them 5 hits. I'm trying to use a case statement to perform this count reset operation, but I can't seem to get it to work. The following case statement works just fine: Code:
Using Limit With Select Or Update Command
How come I can do: select field1 from database limit 10 *shows first 10 records like it should select field1 from database limit 1,5 *It returns first 5 rows correctlly update database set field1='first set" limit 10 *It correctlly updates the field for the first 10 records update database set field1="top 5" limit 1,5 *I get an error that says problem with limit at ^5 check command for correct syntax Is there different syntax for limit when using with a select statement Vs. an update command?
!= Not Working?
SELECT d.cache_diff, d.cache_name, d.cache_type, d.cache_last_found FROM geocaches d LEFT JOIN logvisit ON d.cache_id=logvisit.cache_id WHERE d.cache_status = 0 && logvisit.log_type != 'Found' && logvisit.log_owner_id = 64 This returns zero rows. Its true that records in logvisit.log_type for this user are only FOUND but I am trying to display cache information for all other caches (in geocaches table) that the user did not log FOUND in logvisit. So, basically if the user logged against 3 caches and there are 10 caches available to log agains then I want to display only the remaining 7. Is JOIN the way to go on this one?
LIKE '[0-9]%' Not Working
Here is the SQL query: Code: SELECT * FROM member WHERE username LIKE '[0-9]%' Returns 0 rows. I've tried this on 4.1.7-nt as well as 4.0.22-standard; neither work. And yes, there are records in the table that should match that pattern.
Not Working
I have 4.1.10a on my local machine and the following WHERE clause works fine: Code: WHERE wk1 IN (select max(wk1) from wkpts where teamid = w.teamid) But when I upload it to my web site, I get an sytax error at 'select max(wk1) from...' My web host has MySQL version 4.0.20-standard. Can someone tell me why it would work locally, but not on my web host's server? Thank you.
LIKE '%$var%' Not Working
I am trying to create an sql statement to return values on either side of the variable. Code: $sql = "SELECT * FROM principals LIKE companyName = '%{$_POST['companyName']}%'"; The error was: Error: 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 'LIKE companyName = '%Mike%'' at line 1
Select As Where Not Working!
SELECT CONCAT(RIGHT(dt,4),'-',MID(dt,4,2),'-',LEFT(dt,2)) AS dateavail FROM atable WHERE dateavail = ��-06-01' (dt is a date in format dd/mm/yyyy - the concat bit works fine) Microsoft OLE DB Provider for ODBC Drivers error ?e14' [MySQL][ODBC 3.51 Driver][mysqld-4.1.19-standard-log]Unknown column 'dateavail' in 'where clause' Also, if I get it to work, how do I convert the 2 strings to date so I can look for < and > ?
Doing A JOIN Not Working
I have 2 tables, one contains columns that holds the ID to the other table so eg Table 1 (images) id | imagepath -------------- 1 dir/hair.png 2 dir/face.png Table 2 (buildImages) userid | hair | face 1 1 2 So i'd just like to retrieve a row like dir/hair.png, dir/face.png where userid = 1 does that make sense? Oh, the title of this thread is kind of wrong, shoudl be how do I do this join :P
DATE_SUB() Is Not Working Right For Me.
My `date` column is in date/time format 2007-12-14 19:55:00 When I try to select only the records added in the last 5 hours, I get records from more than 24 hours ago. I know I am EST zone and the server is PST zone, but something else is wrong. This is my WHERE clause: WHERE `date` > DATE_SUB(CURRENT_DATE, INTERVAL 5 HOUR)
Working With SET Type ...
I have this SET(Ƈ',ƈ',Ɖ',Ɗ') on a column. Suppose that the colunm has the data (1,2,4) Now i want to select rows that contain either 1 or 2 or 4. What is the fastest way to do this ?
Left(str. Len) Not Working!
BTW: I am very new to PHP & MySQL learning from the site point book ("Build your own database driven website!"). My Question If i use the left function from the command line, the expected result is returned ok, however when i apply the same query to my web page nothing is returned. This is my query: $sql = "SELECT date_added, short_desc, LEFT(long_desc, 10), news_ID, loc_id FROM location Inner Join news ON globalisation = loc_id WHERE loc_id = Ƈ' ORDER BY news_ID ASC"; $getRows = @mysql_query($sql); if (!$getRows) { exit('Error: Loading SQL statements: '.mysql_error()); } while($listedItems = mysql_fetch_array($getRows)) { $id = htmlspecialchars($listedItems['news_ID']); $news_short = htmlspecialchars($listedItems['short_desc']); $news_long = htmlspecialchars($listedItems['long_desc']); $date_added = htmlspecialchars($listedItems['date_added']); echo '<div class="row_container">' echo '<div class="col_1">' . htmlspecialchars($id) . '</div>' echo '<div class="col_2">' . htmlspecialchars($news_short) . '</div>' echo '<div class="col_3">' . htmlspecialchars($news_long) . '</div>' echo '<div class="col_4">' . htmlspecialchars($date_added) . '</div>' echo '<div class="col_5"><a href="edit_news.php?id=' . $id .'">Edit<a/></div></div>' }
DISTINCT() Not Working
Does anyone have any idea why i can't get this to return distinct values? PHP SELECT DISTINCT(agi.userid), agi.imageid, agi.title, agi.dateline, agi.catid, agi.thumbname FROM a_gallerys_images agi WHERE agi.valid = 1 AND agi.open = 1 AND agi.catid = 2 ORDER BY agi.dateline DESC LIMIT 4
MAX(mainid) Isn't Working For Me???
I am wanting to get the last inserted mainid number then insert back into a different row at a higher number. For example if the inserted mainid was 1 the next number should be 2. The code below isn't working for me. It just adds 0 to the mainid column. Can someone please tell me if there is a better way of doing this? Thanks in advance. Here is my PHP require "config.php"; // more code here $insert1 = "INSERT INTO `menu` (`mainid`) SELECT max(mainid) + 1 FROM menu"; if (mysql_query ($insert1)) { $query1 = mysql_query("SELECT LAST_INSERT_ID() as id FROM menu") or die ("Could not query because: ".mysql_error()); $row1 = mysql_fetch_assoc($query1); $id1 = $row1['id']; $update1 = "UPDATE menu SET menu = '$menu', pagetitleMenu = 'Menu', pagetitle2 = '$pagetitle', pagetitleSub = 'none', subid = Ɔ', submenu = '$submenuyesno' WHERE mainid = '$id1'"; // more code here mysql_close();
Queries Not Working
its been ages since I have worked with MySQL so I am very rusty and am just trying to patch together loads of old code at the moment. $dbh=mysql_connect ("localhost", "*********", "************") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("*********"); $result = mysql_query("SELECT * FROM Update WHERE number=Ƈ'); $row = mysql_fetch_array($result); echo $row['title']; mysql_close($dbh); I keep getting this message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/dcaggorg/public_html/update/index.php on line 18
Working With Dates
After taking a break from this project for a bit I find myself confused about how to pull specific date periods from a database. The timestamps are stored in UNIX format. I'm creating a report builder to pull details about issues that my techs have entered (ISP support center). I can pull reports from calls entered today or yesterday, but getting them from say, mon-fri of last week is throwing me for a loop. Can anyone point me in the right direction? This is what I have thus far: //echo "DateRange: ".$daterange."<br>"; // begin building our query $query = "SELECT * FROM issues WHERE "; // the value passed in date range is how we modify the date lookup in our SQL query if ( $daterange == "today" ) { $timestamp = strtotime("today"); $query .= "DATE_FORMAT(CURDATE(), '%Y%d%m') = FROM_UNIXTIME(issue_submitted_date, '%Y%d%m');"; } else if ( $daterange == "yesterday" ) { $query .= "DATE_FORMAT(CURDATE() -1, '%Y%d%m') = FROM_UNIXTIME(issue_submitted_date, '%Y%d%m');"; } else if ( $daterange == "thisweek" ) { $query .= "DATE_FORMAT(CURDATE() -7, '%Y%d%m') = FROM_UNIXTIME(issue_submitted_date, '%Y%d%m');"; } else if ( $daterange == "lastweek" ) { $query .= "DATE_FORMAT(CURDATE() -14, '%Y%d%m') = FROM_UNIXTIME(issue_submitted_date, '%Y%d%m');"; } else if ( $daterange == "thismonth" ) { $query .= "DATE_SUB(CURDATE(),INTERVAL 1 MONTH) >= issue_submitted_date;"; } else if ( $daterange == "lastmonth" ) { $query .= "DATE_SUB(CURDATE(),INTERVAL 2 MONTH) >= issue_submitted_date;"; } else if ( $daterange == "thisyear" ) { $query .= "DATE_SUB(CURDATE(),INTERVAL 1 YEAR) >= issue_submitted_date;"; } else if ( $daterange == "lastyear" ) { $query .= "DATE_SUB(CURDATE(),INTERVAL 2 YEAR) >= issue_submitted_date;"; }
Fulltext Example Not Working
I'm trying fulltext searching for the first time [Ver 12.22 Distrib 4.0.17, for pc-linux (i686)], but I can't figure out why the example in the mySQL manual is *not* working. mysql> SELECT * FROM articles -> WHERE MATCH (title,body) AGAINST ('database'); Empty set (0.00 sec) mysql> SELECT id, MATCH (title,body) AGAINST ('Tutorial') -> FROM articles; +----+-----------------------------------------+ | id | MATCH (title,body) AGAINST ('Tutorial') | +----+-----------------------------------------+ | 1 | 0 | | 2 | 0 | | 3 | 0 | | 4 | 0 | | 5 | 0 | | 6 | 0 | +----+-----------------------------------------+ 6 rows in set (0.00 sec)
Subquery Not Working
CODESELECT parexel_staff.name, parexel_skills.skill, parexel_activity.date FROM parexel_staff, parexel_skills, parexel_activity WHERE parexel_staff.name = parexel_activity.name AND parexel_activity.skill = parexel_skills.skill AND parexel_skills.skill = 'CGI' AND CURRENT_DATE > (parexel_activity.date + INTERVAL parexel_skills.retake MONTH) AND parexel_staff.name NOT IN ( SELECT parexel_staff.name FROM parexel_staff, parexel_skills, parexel_activity WHERE parexel_staff.name = parexel_activity.name AND parexel_activity.skill = parexel_skills.skill AND parexel_skills.skill = 'CGI' AND CURRENT_DATE < (parexel_activity.date + INTERVAL parexel_skills.retake MONTH) );
Character Set Not Working
I am using 5.0.24 max on my RedHat 8.0. Having problems inserting persian character set into my database. After searching around and doing what was recommended, I still got no where. I am using a firefox -> PHP -> mysql to enter and read data. Reading data from the command line results in garbage. Here is some useful info: mysql> show create database mytest; +----------+-----------------------------------------------------------------------------------------+ | Database | Create Database | +----------+-----------------------------------------------------------------------------------------+ | mytest | CREATE DATABASE `mytest` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_persian_ci */ | mysql> show create table binfo3; | binfo3 | CREATE TABLE `binfo3` ( `id` int(11) NOT NULL auto_increment, `year` varchar(8) collate utf8_persian_ci default NULL, `make` varchar(15) collate utf8_persian_ci default NULL, `model` varchar(20) collate utf8_persian_ci default NULL, `miles` int(11) default NULL, `price` int(11) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=100009 DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci | mysql> show variables like 'character_set%'; +--------------------------+--------------------------------------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/local/mysql-max-5.0.24-linux-i686/share/mysql/charsets/ | Here is how I connect the DB: # cat opendb.php <?php // This is an example opendb.php $conn = mysql_connect($dbhost, $dbuser, $dbpass ) or die ('Error connecting to mysql'); mysql_select_db($dbname); mysql_query("SET CHARACTER SET UTF8"); mysql_query("SET NAMES utf8"); mysql_query("SET CHARACTER_SET_RESULTS=NULL"); ?> In my browser after entering the data I echo the data and it appears fine. I read it back from the DB and its garbage like: ID:100008 Year:۱& Make:بن& Model:۲۲۰ Kilometer:0 Price:0 The & is not suppose to be there. Only 1 char from Year is appearing and 2 chars from the Make appearing. But Model looks fine! Kilometer and price are not accepting any inputs!
SELECT Not Working
SELECT U.*, G.Name AS groupname, C.FirstName, C.LastName, (Select count * from Account Acc where Acc.User_ID = U.User_ID) as Account_ID FROM ((Users U LEFT JOIN Groups G ON U.Group_ID = G.Group_ID) LEFT JOIN Customers C ON U.Customer_ID = C.Customer_ID) WHERE 1 = 1 The above returns a 1064 Error on SUSE Linux MySQL 4.0.18. But on WinXP MySQL5.0 all runs fine. Can anyone give me advice on how to fix the above to work? If I remove the second select from the query all works fine.
PHP Not Working With MySQL
Just starting out and I have PHP, Mysql, and Apache installed. PHP and MYSQL dont seem to be working together. Everything seems to be running fine and I edited the httpd.conf in order to allow apache to process php requests. This is what I am doing when I start mysql... c:/net start mysql c:/mysql/bin/mysql -u root -p Then I log in and it accepts the log in. When I create a sample php program like "Hello", it works. But when I do a simple sql connect: <?php $conn = mysql_connect("localhost","root","tntboy"); echo $conn; ?> I get nothing! Nothing at all comes up on the screen. Any ideas? Why is it not connecting to the database?
Foreign Key Not Working
I am using mysql server 5 version, and heidisql version 3.0. i am adding a foreign key to an already existing table the exact command is ALTER TABLE mailer_contact_details ADD CONSTRAINT mcd_fk FOREIGN KEY (address_id) REFERENCES addresses(id) on delete set null there is no error, and i am getting query ok, but the foreign key functionality is not happening, i am able to enter the value in the child table which is not present in the parent table, and still no error message is getting displayed i even created an index for address_id field, and then again giving the above command, still foreign key functionality is not working.. where is the problem?
INSERT Not Working
I have the following: mysql_query("UPDATE tblmembers SET loginDateTime = NOW(), MemberApproved='A' WHERE ID = '".$_SESSION['mid']."'"); mysql_query("INSERT INTO tbllogins (MembersID, loginDate) VALUES('".$_SESSION['mid']."', NOW()"); The top line works perfectly, UPDATE'S both columns in table tblmembers, the second line doesn't work at all... It isn't INSERTing any data into tbllogins...
Still Cannot Get MySQL Working
I have the MySQL server running. I have installed MyODBC. I cannot get either the Migration Toolkit or the MySQL Administrator to connect. I've turned off the Windows Firewall and put exclusions in Norton to allow port 3306 and MySQL. With the MySQL Administrator I get an error message of Cannot Connect to MySQL Server on localhost. With the Migration Toolkit I get this error log: Code:
Mysqldump Not Working
I created a backup of my databse using: mysqldump --opt mydb > "c:ackup.sql" when I try to restore the database with mysql mydb < "c:ackup.sql" I get an error saying 'c:ackup.sql' incorrect database name.....
No Timestamps Working
I've tried just about every php/mysql combination out there in order to make this work, but even when it seems that it should work, it doesn't. It must be comparing strings or something, because I've tested the numbers, and the numbers themselves would have worked properly. What I'm trying to do is create a "Who's Online" box for a forum. I've already created a timestamp record in my user table, and they're updated with NOW() whenever somebody navigates anywhere on the site. I've tried to run this with many functions, and the most recently failed one is this: $query = "SELECT recorda, recordb FROM usertable WHERE timestamp >= " . (date("YmdHi") - 10) . date("s"); $result = mysql_query($query); ...
Working With Dates...
How would I finish a query like this: SELECT * FROM table WHERE datetime_field BETWEEN NOW() AND <tonight at midnight> I'm not sure how to calculate "tonight at midnight" in a format that can be compared to the result of NOW(). Any ideas?
NOT NULL - Not Working
I have created an HTML page that has an Iframe on it, linked to a PHP page. When I refresh the HTML page (and thus the PHP page), it will resend the code to MySQL, creating a blank row (except date, which is automatically entered by a variable with the PHP date() command), even if the HTML forms yield no value. Here is the code: CREATE TABLE withdraw ( id int NOT NULL auto_increment, reason varchar(20) NOT NULL, amount decimal(8,2) NOT NULL, date varchar(20) NOT NULL, primary key (id));
Working With 'SET'
I would like to know how I can work with a PHP Array and a set. How can i get all rows where a set where at least one item oft the php Array is inside the set column?
AUTO_INCREMENT NOT WORKING
I have set all my foreign keys to AUTO_INCREMENT, but when I insert a new record I have to insert the next number manually. Does anyone know why the number isnt automatically incrementing?
Working With Images.
mysql 4.0.24 I have an existing database that has image information. It stores the path, filename and some other items. I'd like a way to store the thumbnail of the image in the database. I still want the image as a file. I'm having troubles figuring out exactly how to add the thumbnail. I can manually use convert to create the thumbnail. What I've found on the net are just methods for uploading a single image, then adding it to the db. This will be a one time shot to update the DB. Pick a language, I'll figure something out if I can get the key to this.
Recordcount Not Working = -1
Why wont this work? The Recordcount is > 90. I can get the records, do select, update, and delete. WinXP pro ASP 3.0, VBscript MySQL ODBC 3.51 Driver MySQL 5 code: <% Set DBConn = Server.CreateObject ("ADODB.Connection") DBConn.Open emailDSN set RS = Server.CreateObject("ADODB.Recordset") sqlQuery = "select * from web_email" RS.Open sqlQuery, DBConn, 3, 1 Response.Write("<h1>Recordcount = " & RS.Recordcount & "</h1>") RS.close set RS=nothing DBConn.Close set DBConn = nothing %>
My Cursors Are Not Working
I have this code: create procedure pruebacursor () begin declare a char(5); declare done int default 0; DECLARE cur1 cursor for select substring(link,1,3) from animals; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1; open cur1; repeat fetch cur1 into a; insert into names values (a); until done end repeat; close cur1;
Not Working As Expected
All i need is to insert data from the disk to a table. The Text File: 30434 menios 30567 dimitris 30666 skatas 30123 testing SQL syntax: mysql> load data local infile 'c:sub.txt' into table m; Query OK, 4 rows affected (0.00 sec) Records: 4 Deleted: 0 Skipped: 0 Warnings: 0 mysql> select * from m; +-------+-----------+ | am | name | +-------+-----------+ |434 | menios |30567 | dimitris |666 | skatas | 30123 | testing | +-------+-----------+ 4 rows in set (0.00 sec) Why is that happening? - my PC: MySQL last version (5. ..), win32 - It works fine under linux! 'Describe' of m table mysql> describe m -> ; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | am | int(11) | YES | | NULL | | | name | varchar(10) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec)
Limit Is Not Working
I have created a trigger: I am using if not exists(select field1,field2 from table1 where name1=?name and section1=? section limit 1) then .....start insert process......on a certain table end if; I am using limit 1 to return only 1 row to start insertion, but it seems that limit doesn't work when we are using if not exists... If anyone has any other suggestion, it would be great. Also I used: but it doesn't work with this var variable: ///////////////////////////////////////////////////////////////////////// declare var varchar(400); set var=null; set var=select field1,field2 from table1 where name1=?name and section1=? section limit 1; //why set it doesn't work here, to check nullity if(var=null) then //we check nullity like this?????????? insert into table 2(field11,field22) values( 'x','y'); end if;
PhpMyAdmin Isn't Working
OK, phpMyAdmin can't create a table, it produced this code: CREATE TABLE `photos` ( `name` VARCHAR( 255 ) NOT NULL , `desc` TEXT( 500 ) NOT NULL , `url` VARCHAR( 255 ) NOT NULL , `cat` INT( 4 ) NOT NULL , `id` INT( 4 ) NOT NULL , INDEX ( `name` , `desc` , `url` , `cat` , `id` ) ) and this error: MySQL said: #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 '(500) NOT NULL, `url` VARCHAR(255) NOT NULL, `cat` INT(4) NOT N .
Select Where Not Working
i've been testing on a select statement on mySql 4.0.18 with the following statement and it worked fine $result = mysql_query("SELECT * FROM rate WHERE 1 AND country LIKE 'Kenya' LIMIT 0, 30",$db); however i'm now using a friend's isp and they have mySql 4.0.20 and the statement above doesn't work, a select * from rate however does work.I need to select a specific country from a single table and output the results onto the screen.
Rand() Not Working In Php?
I'm trying to get the rand from the mysql. When I use the MySQL Front software (SELECT * FROM keyword ORDER BY RAND() LIMIT 2, it gives me random which is working fine. But when I use the php and it doesn't give me random. What wrong with php? $query = "SELECT * FROM keyword ORDER BY rand() LIMIT 2"; $result = mysql_query($query) or die("Query failed : " . mysql_error()); echo "<PRE>"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print_r($line); } echo "</pre>"; mysql_free_result($result);
|