Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Syntax Problem With The WHERE Command


I have it run a query with $_GET['name'] as my variable

in this case it's always two words, ie "John Smith". I used the urlencode and urldecode functions in PHP to pass the whitespace from one page to the next, but when it's used to run the query it produces and error as a result of the whitespace.

What is the proper syntax for this line right here?

SELECT * FROM `table` WHERE name=john smith

The whitespace there causes a syntax error, is there a PHP function I can use to fix this problem?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
MyODBC Command Syntax
I'm trying to do what I thought was a fairly simple thing, select a group of
records from a mySQL database.
I'm not much of an SQL guy. The syntax I would use for Microsoft SQL is
shown on the "query =" line.
A myODBC error message indicates this is not supported syntax.
Can anyone help me?

{ ADO Startup Values and Creation using the .Open method}

{Create a COM object reference to ADO Recordset.}
recordset = COM_CreateObject("ADODB.Recordset");

{ Open a Recordset }
query = "SELECT * FROM t_course_date
WHERE(modified>=CONVERT(DATETIME,'1999-07-31 00:00:00',102))";
("modified" field above is a mySQL field name)

recordset.Open(query, 'connection id', adOpenDynamic,adLockOptimistic); <--
This statement fails.

Syntax Error In INSERT Command
I am trying to insert some data into a field of one data entry. For some reason, despite the fact that I used the same syntax as I have previously, I keep getting the syntax error message. Here is the query I created:

$insertquery = "INSERT INTO employeeskills ($forminput) VALUES (1) WHERE employeeid = '$employeeid'";

The error message says there is an issues near "WHERE employeeid = '"

Any ideas?

Command Line Syntax For Script
Have a script that creates and populates a table which will execute via the EMS MySQL Mnager Lite interface if you open the database 'test' and run the *.sql script.

The *.sql script is located in the 'data' folder which is the parent folder of 'test'.

Having opened the database 'test' through the command line, what is the correct syntax to run the script, please?

Checking Command Syntax Without Execution
Is there anyway you can run one more sql commands (via mysql) to just check for syntax without actually executing the commands.

Syntax Error With Mysql LOAD DATA ... From Command Prompt
I have a script:

mysql -u dbuser -ppassword -e "LOAD DATA INFILE '/appl/tmp/mysqlwr.txt'
        INTO TABLE dbfile.dbtable
        FIELDS TERMINATED BY ':'
        ESCAPED BY ''
        LINES TERMINATED BY '
';"

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 'orange' WHERE `ID` = '11128'' At Line 1
I am getting this error message everytime I run my php script....
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 'orange' WHERE `ID` = '11128'' at line 1

It seems that there is a limit on the where syntax. I don't know how to fix it, and it's a very big problem for me.

My task is to insert 1million values into mysql table with a php foreach loop. If I insert aprox. 10.000 values, this error don't come, but any numer over will give my mysql error.

Command To Use
Is there a command that I can use to select a row that contains a particular word in a series of words?

For eg. how do I select the row that contains "I am Neo and I hate Smith" in a column if I just search with "Neo"?

Command
I moved my forum to another folder and now all the references in the database still point to the old folder. What command can I use to update all the URL's in the database to the new folder?
EDIT: Nevermind, I figured it out.

++ Command In SQL
I am developing a website in MySQL and PHP at www.zakirium.com. The site is supposed be a listing of the best freeware on the web. I'd like to be able to keep track of how many times each piece of software is downloaded. Is there a type of ++ command that could be used with an UPDATE command in PHP that would increase the number in the database column by one, so every time there was a download, the number would increase by one.

Best Command
i would like to know the best command to do backuping of the tables in the databases.......

i'm using MySQL 4.0 on a solaris 9 OS .....

SQL Command
If in my data I have for title the values Marketing Manager, Manager, Database Manager and I use LIKE 'Manager' I would want to return all titles with the word Manager or Managers etc. My code only returns an exact match. Can this be easy to do?

Code:


SELECT * FROM jobtitles j WHERE `title` LIKE 'Marketing Manager';

Where Command
If I want to update multiple rows and set the same column in each to the same thing, how would I go about doing that?

UPDATE gfx SET creator = 202 WHERE id='1,2,3,4,5'

Obviously that doesnt work, can I make an array somehow? Or do I have to use a bunch of or s?

Sql-command
why doesn't work this sql-command? it gives me a syntax-error:

SELECT *, IF((SELECT COUNT(*) FROM A, B WHERE A.pk = B.fk) > 0, 'true', 'false') FROM A;

the inner sub-selection itself works fine:
(SELECT COUNT(*) FROM A, B WHERE A.pk = B.fk;

also this would work:
SELECT *, IF(1 == 1, 'true', 'false') FROM A;

I'm using 4.0.21 - might it be too old for this command? if yes, how could I get it otherwise?

Sum Command
This may be a silly question but my knowledge is very very limited.
If I have 6 columns, say a,b,c,d,e,f and i have a entry where values were

a=1
b=2
c=3
d=1
e=2
f=3

If I wanted a sum of cells a,b,c and output a new column called abc and then a sum of cell d,e,f and output a new column called d.e.f how do I go about it ?

select
sum('a,b,c') $abc
sum('d,e'f) $def
from detailsas said, knowledge is very limited,

Command Line Help?
Say I have a column 'apples' with entries:

green apples
red delicious apples
granny smith apples
golden delicious apples
McIntosh apples
Jonathan apples

is it possible to run a query looping through all entries (like 1000s of entries) taking out the redundant ' apples' from each entry from the command line?

How Do I Get To The Command Line?
I read an entire book on writing MySQL and PHP without testing everything on the computer at the same time. The code all seemed to make sense to me while I was reading it, but when I finally sat at a computer to enter the code I realized that I had no idea where to begin entering it! How do I get to the "command line" to start using MySQL on Windows XP?

Command Line
If I am running MySQL as a Windows Service, how do I obtain the command line?

Use Command In Mysql
Is there any command in mysql to unselect the database, opposite command of use.

CHECK Command
Could I use the check command to see if a certain identifier will never exceed a default value when data is put into the table.

capacity INTEGER NOT NULL DEFAULT 10,
CHECK(capacity<=10)

GROUP BY Command
I've got a table with following fields and data:

int int double
article,userid,price
1 1 10
1 2 15
1 1 20
2 1 10
2 2 20
3 2 100
3 1 200

What I want to know is, which user pays the highes price for every
article. And this in one sql-command. The Result have to look like
this:

int int double
article,userid,price
1 1 20
2 2 20
3 1 200

Any ideas?

Difference Command
I was wondering has anybody ever used a 'Difference' command in SQL*Plus. I want to compare a table and a view and return the data on one and not on the other. Any ideas

Delete Command
I am trying to delete rows from a table when columnA = 1 and columnB =2. I cannot figure out the command.

GROUP BY Command
I've got a table with following fields and data:

int int double
article,userid,price
1 1 10
1 2 15
1 1 20
2 1 10
2 2 20
3 2 100
3 1 200

What I want to know is, which user pays the highes price for every
article. And this in one sql-command. The Result have to look like
this:

int int double
article,userid,price
1 1 20
2 2 20
3 1 200

Any ideas?

Source Command?
I have a users.sql file that I want to import into mysql. When I tried this
source F:gusers.sql

It gives me an error like this:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use n
ear 'source F:' at line 1

ERROR 1102 (42000): Incorrect database name 'sers.sql'

but if I copy this file into F:data and use the command source F:datausers.sql
it worked fine.

Cannot Log On Via Command Prompt.
Our entertainment division uses MySQL as the database of choice for their various websites. They are not command-line-type people (who would want to that? i mean I like command line OK, but I'm weird). Using their PHP Admin program, they administer the databases quite efficiently.

All of us can log on fine via the PHP interface. Additionally, I've installed the MySQL ODBC in a few places and it works fine. We all use the username root and password abc. No problems.

My problem is that I can't access the MySQL server via the command prompt.

I do this:
CODEc:mysqlinmysql -u root -p

Using Source Command
I'm using mysql 5.0 on a WinXP system.

I thought I could use the source command from the mysql> prompt to read text files containing sql statements to do things like create tables, but no matter what way I type my file name the source command says it can't open the file.

ERROR:
Failed to open file'"foo.txt"', error: 22

I've tried quotes, no-quotes, full path, 's, /'s.

SQL Insert Command
Have a small database up and running (downloaded mysql) works fine. can select and even insert more rows. Made my sql file from notepad. However when i connect and insert a new row it works till i shut down the database.

Once i run it again ( reboot) it is not updated or not there anymore.

I tried the commit; command as well but i can not get it to save my new rows on the harddrive.

Addition Within Sql-command
given i have a TABLE1 with a FIELD1. FIELD1 contains an integer number. Now I'd like to increase that number by 1 (number ++). Can I do this within one mySQL-statement?

Describe Command
I want to retrieve information regarding table columns .I tried using the describe command but the sql server stops on execution of the same .

When I try the query "Show columns from tablename" I get the same response.

I am using MySql version 5.0 .
Could anybody please let me know whats the problem with these commands and is there any alternative to them .

Using The Mysqldump Command
I've been doing some research into creating a backup script for my PHP website. Using the mysqldump command looks like the best way to go. I am unsure on one thing though - where does it save the file to?

Like if I don't specify a path to the file, just something like 'dump.sql', then where will it save the file to? And how do I make it save to, for example, the root folder of a users website? My script may be on different websites so the path to the root folder of the website may change.

Command Editing
I'm running mysql 4.1 on a Mandrake 10.1 machine. When I try to edit commands using the arrow keys, many keys don't work properly, most notably the delete key.

That is, if I make a typo at eh beginning of a long command, I have to way to correct it. Entering the delete key just echos tilde characters in the console.

The bash prompt itself recognizes all these keys correctly. This sort of command editing seem to work fine under Win2K at the command prompt.

Mysql BETWEEN Command
i just want to know on how can i query certain part of data using the date.what i mean is, i want to query for example the data from 2005-04-25 till 2005-04-30.i've try the sql code below,but it does'nt work.can anyone give me an example on how can i query using mysql??plz help.tq

rsLetterDate.Open " select * from letter BETWEEN letter.letterdate = '2005-04-01' AND '2005-05-31'", "DSN=Data", adOpenStatic, adLockOptimistic

Command Line
I'm looking for a command line call that can copy a database table (db1, table1) to another database (db2, table1).I know there has to be an easy way to do this but I can't seem to be able to find the magic syntax.

GRANT Command
I want to allow a user to do external querys (from different PCs on Internet) ..

I think I should use GRANT, but dont know how...

Could anyone tell me a sample to do this ?

I think I should use a "user" and "password" with GRANT...but...Any suggestion ? Is this user/password the same as I have on mySql setup for administration of the DB...?

Command Line
Error
You have created a new database, but have not yet imported the 'cacti.sql' file. At the command line, execute the following to continue:

mysql -u oursite_cactiuse -p oursite_cacti < cacti.sql

http://monitor.hostingcorral.com/cacti/install/
Where do i put that line at?

Use Of The 'IN' Command In SQL Statement
I can't for the life of me figure out why this use of the 'IN' command does not work with my SQL. I have tried the SQL statment within the In command and it works fine but when i use it in the below SQL statement it does not work, and doesn't really tell me what is wrong.

Command For Reversing
How would I go about undoing this operation? I 've been searching for the reverse of CONCAT but the MYSQL manual doesn't seem to show this.

UPDATE products_to_warehouses
SET warehouse_sku = concat('SYNC',warehouse_sku)
WHERE warehouse_id = 3

I want to remove the SYNC that I have at the beginning of every record.

Command Line
how to change my mysql password on command line

Command Could Dump
which command could dump the schema of all tables, but JUST schema ?

Command Line
I am trying to run the mysql_fix_privilege_table.sql script but have no knowlege of the mysql commandline. So far i have 'mysql --force < mysql_fix_privilege_tables.sql' but this gives me the 'ERROR 1046 - No Database Selected' how can I select to apply the .sql script to ALL databases?
I tried using phpmyadmin but I cant see the option to run scripts

Command Question
This is my first post in this forum, and I had a question about running mysql via the command line client. I'll give you the background. I am using NSIS to create an installer and need to execute some sql files via batch.
I am using "mysql -u root -p DB < mysql.bat" to execue the files. The only problem is that the Enter Password: ********* thing always pops up. I can't really have this showing up because the users who will be installing this won't know what to do. The root account will not have a password setup at this point in the process.
So I guess my question simply is: Is there a way to bypass the need for the user to enter a password if the database is on that computer with no password?

Command List
Is there a simple way to display _ALL_ user-created variables at once via a single command?
Using 5.0.18-nt.
In a connection session I create lots of user variables: @siteloc, @itemtyp, @amtset, and so on.They are used in different places during the connection.

Show [Global | Session] variables does NOT show the user variables. It is so annoying and time consuming to have to go backwards thru the command list to find them.
How to show them all at once?

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.

Mysqlimport Command
Has anyone tried to use "mysqlimport" to import a comma delimited text file with SQL commands in it?
I have tried using the following:-

mysqimport -f Table2 /usr/home/ariff66/table2.txt;

but keep getting an error 1064 - error in the syntax. (-f is because a Table2 doesn't exist)

Command Line
I connect from a Windows command line ...mysqlin>mysql myuser mypass
and all that ever gets displayed is this help text :

Usage: [OPTIONS][database]
....
....
....
Variables
....
....
....

there's no >mysql prompt after that, it's only mysqlin>

So then I reconnect and try adding options or queries but it always
does the same thing. I can query from php scripts at http://localhost
but the the command line.

SOURCE Command
i am new to mysql.i have a file full of sql statements
like
insert into mysql1.table1 values(4343);
.
.
.
now i want to run these statements and create my mysql table with data in it.
i was told to use a SOURCE command but iam having problems
from the mysql prompt i tried
mysql> source test.sql ( this is the file that has all the sql statements)
and i got "file could not be located" error: 2
my questions:
how can i syntactically specify the location of my file ?
will the SOURCE command serve my purporse?

Select Command
I tried something like this Code:

SELECT * FROM db where Db = '%test%';
[code]

that would show me list of data (rows) that have a column that match the 'test' wording... Like "subtest", "abctestdef" and "test" for example... But that doesn't seem to work, so what is the correct symbol instead of "%"?? I'm using MySQL 5.0.16...
Edited: Never mind. Found it via google search instead of mysql search, it said I need to do this for it to work..
[code]
select * from db where Db like '%test%';

Connect Command
I'm new to MySql and I'm having a problem figuring out how to configure my
Connect command so I can test on my PC and upload scripts to my ISP without
constantly changing the Connect command to reflect the applicable host. I use
LocalHost on my machine and then change it to my ISP's IP on their network before
uploading the scripts. I'm sure there's something I'm missing in the manual
about setting up Grants.

How To Undo DROP Command
I have done the unthinkable. I accidentally dropped a table which had no current backup. It's been a couple of hours since I ran the command. Is there any way to recover this data?




Copyright © 2005-08 www.BigResource.com, All rights reserved