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




Use Quotation Marks In Insert Into Command String?


how to make SQL command with cuotation marks for example
INSERT INTO some_table (name, pet) VALUES ( ' Petar's ' , ' dog ')
is there any way to put quotation marks inside the string, or should I make some statements for chechking if the string has quotes and replace them????




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Removing Quotation Marks
Say you had a column with character data that contained quotation marks. How would you update this column to remove the quotation marks? update table set description = replace(description, 'xx', 'xx') but instead of the x's replace quotations " with nothing since you cant put the quotes directly into the first parameter of the replace function?

MySQL Is Adding Quotation Marks When Uploading Tab-delin. .txt File
In the Excel sheet, the data looks like:

Data that is going into a page.

and is coming out

"Data that is going into a page."

It doesn't seem to be causing errors, but the formatting looks like crap.

Inserting A String Containg Quotation Character
I was encrypting a string and inserted it to mysql db, when displaying the encrypted string, it has no quotation character but when I inserted it to my db, I got an error using near "xxxx' where xxxx is of any character. I use VB code. it has no effect when using replace command.

String Error - Quotes Changed To Question Marks
I recently converted an asp/access site to an asp/mysql site. Now all my strings are displaying funky. For example if I have the text - Why don't we say "Yipee" - it displays on my site as - Why don?t we say ?Yipee?. The same change is being made when I use a sentence with "..." in it. I like ... baseball is changed to - I like?baseball.

Any thoughts as to why this is happening? Sometimes it is actually being changed somehow in the database, and sometimes it is correct in the database, but then changed when it displays on the web.

Insert A String
may i know how to insert a string which contains double quotes? for example ,this may not works:

insert into string values(" this is my "name" ")

Insert String Problem
My string contains the degrees character, CHAR(167)
How do I include this within a string?

INSERT VALUES ('preheat oven to 350'CHAR(167)' F.');
does not do it. Any ideas?

String: Insert Multiple
I have strings with no "
" in a text field. I need to output each string with with a "
" after every 60 characters. In other words I need to change the line length from unlimited to 60. I do not want to change the stored version of the data, just the output.

What is the best way of doing this SELECT?

Insert A String Of Values
as you will see iam new to php/mysql and desparately require some help. My problem is as follows -
i need to enter a string of values from a list or selection of checkboxes into ONE field. Iam using dreamweaver and although it has the option for multiple entries it only inputs the first selected in a list. all i need it to do is be able to input for example beach facilities
- toilets, slipway, lifeguard
into one field from a list of facilities. i don't need to separate them at a later date as i will display them just as above. Your help will be greatly appreciated as it is a reg charity based website for marine wildlife that iam trying to construct.

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.

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?

Running A Modify SQL Command, When A INSERT Is Done On A Table
I have an encrypted PHP script that runs on MySQL back-end.

I want to modify the record entered by the script to the DB table, after every INSERT record..Since script is encrypted I can't change anything from PHP end..

How can I do this?

Apostrophes Turning Into Question Marks?
This may be easily resolved but I haven't ever encountered it before. I am entering text into my mysql database that contains apostrophes. This field is generally around 500-800 characters. When I add the information, there are apostrophes but when I go back to use the information, all of the apostrophes have been changed into question marks.
Any ideas how to keep the apostrophes? or why they are being changed?
Also, if I go through and change all the question marks back to apostrophes, they will stay apostrophes!


Double Quote Marks In SQL Backup File
when I do a backup of a table on my mySQL Administrator I get CREATE TABLE "product" (double quotes), I want product` (single quote marks) where do I specify this I tried all I can imagine already to do with character set..and backup options
(this messes up on restore with double quotes on DB I need to add this to..

Format Function In SQL String To Return From Numeric Field In Table To String
How would i form a format function in SQL string to return from numeric field in table to string:

1 --> '001'
5 --> '005'
57 --> '057'
125 --> '125'

How Do You Replace A String With Another String
How do I write a query in myPHP admin to search through a particular field in a particular table for a string and replace it with another string? The string is only a part of the value of that field. For example, how would I change "Hello there" to "Hi there"?

Insert Multiple Rows With One Insert Stmt And Nested Select
I'm trying to insert several rows into a table using only one insert statement:

insert into component_feature values (select 3,1,sf.software_feature_id,1 from software_feature sf where sf.software_id = 1)

When I run the select statement alone, I get the result I want:

+---+---+---------------------+---+
| 3 | 1 | software_feature_id | 1 |
+---+---+---------------------+---+
| 3 | 1 | 0 | 1 |
| 3 | 1 | 1 | 1 |
| 3 | 1 | 2 | 1 |
+---+---+---------------------+---+

But when I run the complete statement I get:

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 near 'select 3,1,sf.software_feature_id,1 from software_feature sf where sf.software_i' at line 1

This query is part of a PHP application I'm building. I'd rather not have to write a PHP loop to do multiple inserts.

How To Insert Multiple Rows With 1 Insert Query
I am having a form on the front end which has for example 3 rows each with 3 columns. The user enters data in all the 3 rows. When he hits the add button these should get in the database. What insert query would I write to add all of them together to the database? Do I need to use some procedure?

SQL String
I have VB6 app connected to a MySQL 4.1 database.
I am using ADO and myODBC to connect to the database on a webhost, and successfully return data to my forms.
My problem is that I need an SQL string to call records where the date is equal to today.

The string I've used is like "SELECT * FROM tblCalls WHERE CallDate='" & Format(Date,"yy-mm-dd")'".  When I populate my ADO control, with the SQL as its recordsource, I get all records back, i.e. it won't filter by today's date.
Can anyone tell me how I need to construct my SQL string to apply the filter I want?
Apologies if there's already a post about this, but I've tried to search this forum, and the MySQL forum with no luck.

Get String Of Certain Fields
Hi all! please bear with me as im not familiar with mysql... just can set up a database but thats about it.
I have a table for clothing, and for each item i have an 'enum' field for every colour available where i choose a Ɔ' or Ƈ' depending whether that colour is available for that item or not. There are many other fields in this table but the colours are the only ones im concerned with at the moment.
I'm just after how to get the string with the colours, that i can then explode onto my page. Once they are set out in a list im after adding a checked="checked" option to the radio button of the 1st item displayed.
Im not sure whether i'm making any sense whatsoever so you can view the original thread i made in the php forum that reffered me to here. Sorry if this is pretty vague let me know if u want me to elaborate on anything

String As Primary Key
www.site.com/abc
www.site.com/xyzzzz

"abc" and "xyzzzz" are names of products, and are unique.

This would mean that in my database design, I store the product ID as a string (primary key). Does this impact performance speed at all, vs. if I stored the product IDs separately as a number?

I've thought of storing them as numbers, but then it wouldn't be as easy to remember. Users would have to type:

www.site.com/3235389

to get to product "abc". However nobody would remember a number. It would be easier for them to remember "abc".

What are your thoughts? Storing a string (can be up to a few hundred characters long) as the primary key, is it ok for performance?

Which String Type Should I Use?
I am currently using a Text string type to store some webpage data. The webpage is not that large.

What is the maximum number of characters a Text string type can hold?

String And Memo
I am a delphi programmer.

I have created (manualy on the server) one table with this structur:

id - int auto increment primary key
name - varchar(50)
nipc - varchar(9)
....

After creating the table i tried to access to the table with my delphi application but it gets the fields varchar like memo.

But if i insert values with the line

insert into teste(nome,nipc) values('Marco','teste');

it interpretes the fiels like string, what is the problem?

I access the tables via odbc, with delphi 7, Mysql 4.1.

Searching A String
1. I have a list of states in a single variable, as such.

AZ CA NY NM OR


2. What is the best method to pull a match on a single state?

WHERE variable is LIKE value?

In JavaScript, I would use the indexOf like so.

if(var.indexOf(value) > -1){
THEN TRUE
}

Is there something that matchs the JavaScript IndexOf ?

TYIA!

String Matching
If i have the following table:

--------------
| ID | Color |
--------------
| 1 | Blue |
| 2 | Red |
--------------

If I have a HTML form and the user inputs in a textfield "The sky is usually blue in color".

String Comparison
I need to search a table for certain area codes. Because the office does not have a uniform way of entering phone numbers into the database, some are entered as (555)555-5555 and others as 555-555-5555.

I have a select statement in which I want to return phone numbers beginning with a certain area code indepent of how the phone number was entered.
I've tried the following:

CODESELECT customers_telephone FROM customers WHERE customers_groups_id = 3 AND customers_telephone
like '(310)%' OR customers_telephone
like '310%'

String Parsing
I am having a problem making an online form and I am fairly new to php and MySQL. I have an online form that errors when either single quotes are used. My code looks like this:

"INSERT INTO ".$_POST['gender']. " SET " .
"Name='".$_POST['school']."', "....

So if for example the name of the school were O'Connor, there would be an error with the parsing. Is there a way to fix this issue.

String Comparison
I would like to search a column of strings for matches to a given prefix. Is there a way to use existing string comparison functions to do this? Specifically I'm looking for the number of leading characters identical to my (variable) search string:

Example: looking for matches to prefix "Robb"

SELECT names, some_functions(names, "Robb") AS m FROM etc, etc, etc...

| names | m |

| Roger | 2 |
| Robert | 3 |
| Roseanne | 2 |
| Cary | 0 |
| Randy | 1 |
| Robby | 4 |
| Allison | 0 |

Return the highest value of m for which LEFT(names,m)=LEFT("Robb",m).

I've been reading through the section on string comparison function, but can't find anything suitable. But perhaps there is some combination of funtions you could use?

String Comparison
When i update a table i am carrying out a check to see if that entry already exists. This is ok when it is the same case but when it is different it allows it.

select
count( entityid ) as COUNTENTITIES
from
entities
where
code = '%1%'

I have tried LIKE but that didn't work either

What i am after is if there is a code 'c1' in database and someone tries 'C1' i want that to fail because 'c1' is already there. Is this possible?

Binary String?
In what case, I could use binary string?

String Comparisons
can someone please tell me where this statement evaluates true

select 'C:Documents and SettingsJudyVMy DocumentsDSC02062.JPG'='C:Documents and SettingsJudyVMy DocumentsDSC02072.JPG'

and how do i get it to evaluate false.

Format String
I have a large text file that I need to format so I can use a mysql command to populate a blob cell.

Is there an insert comand what will take my txt file and insert it into a cell from a remote computer?

Remove From String
I'm looking for some way to remove a part of a string from a table.

I have a table with a field called id. It contains data like this:
;1;6;9;34;54

What i want to do is to be able to remove ie. ";34" from this data, kind of oppisit of CONCAT. Hope that I explain myself well enough.

Do I have to extract all data, remove the substring and save the data in the db again, or is there an easier way?

How To Turn A String Into A Set?
If the string is in the form, say,

'setvalue1,setvalue3,setvalue7'

or 'setvalue2' if the row is a member of just one set.

Using An Apostrophe In A String.
Is there a way to pass an apostrophe from a webpage to a MySQL TEXT column? I have an area on my site where users can update their project details and I can foresee running into problems with the usage of apostrophes. I understand the error is in passing the INSERT command:

***
"INSERT INTO projects VALUES('1', '123456', 'Some Client', 'These are the project's details', 'Project Leader') ...

***

I understand that MySQL is thinking I mean to close the variable with the ' in project's.

Converting In To String
I have a table that has a field, subscription_id that is an unsigned long, and an account_number that is a string. I want to set the value of acct_number to be equal to the subscription_id converted to string form.

Get Min & Max Values Of A String
I have a field 'zip' in a table in my database that records values in the form on 'something/023/something', 'anything/346/somemore','kztt/1984/asdg'

I want to get the min and max values of this field in particular the numbers in the string. Initially, I simply run a query to get the min and max value of this field which works until the numbers in the string went to 4-digits instead of the usual 3.

Example query: select min(zip) as min, max(zip) as max from $dbtable

Then I run an explode function to retrieve the numbers in the string.

This query now return values like min=999, max=1000 instead, when the min number should be 023 and max is 1984

Selecting String
I am having a problem on selecting strings in mysql.

I have the folowing column:

|////////////////////////////////A\\\\\\\\|
+-------------------------------------------------------------------+
| 1A11B01C01D11E12A12B02C02D12E03A03B03C03D13E2 |
+-------------------------------------------------------------------+

What I would like to do is get this string giving a letter. Example:

I want letter B, then the result should be this: 1B02B03B0.

Got it? I give the letter and it returns me the prev char, the letter, next char. Only. Can mysql do this?

Efficiency Of String Vs Int
Is the difference in efficiency of a string in mysql vs the efficiency of an int drastic enough to avoid using an int? I'd like to use strings for readability of types but I can just as easily use ints like a C enum.

Error In String
I'd like to use placeholders but it looks difficult to use with $dbh->do() as I am not particularly familiar with this.

CODE  $dbh->do("INSERT INTO storage (url, altavista, yahoo, msn, teoma, google, alltheweb,Total, lastsearch, totalsearch) values($url, $altavista_results, $yahoo_results, $msn_results, $teoma_results, $google_results, $alltheweb_results, $total,$time, $total)") unless $dbh->do(UPDATE storage SET (url = "$url", altavista = "$altavista_results", yahoo = "$yahoo_results", msn = "$msn_results", teoma = "$teoma_results", google = "$google_results", alltheweb = "$alltheweb_results", total = total +1, time="$time") > 0;

Interpret String As Sql
Is there a way to interpret the content of a string as sql?

String Operation
If i store a comma separated string(1,2,3,4) in a varchar field.Is there any operation using which i can retrieve the valuse 1,2,3,4 individually an use them in another query.

Incorrect String Value
while length(trim(mytext)) > 0 do
set var1 = SUBSTRING_INDEX(ltrim(rtrim(mytext)),' ', 1);
set pos = pos + 1;
set textlength=length(var1);
set mytext= SUBSTRING(trim(mytext), textlength+1);

insert into pddt values(doc_id,pos,var1);
end while;

When this loop runs i encounter this error "Incorrect String Value".
I was checking each and every line in this loop and found out that substring_index is causing this error(I Believe).

Mytext va

String Manipulation
I need to remove the html tags from a varchar field in the where clause. do you know how I could achieve this? this is how I planned to do it, but I can't find the appropriate function:

select * from test where replace(myfield,"<*>","") = "xoxox";

this replace function would replace all of the <html>, <a>,... from myfield with "".

String In The Database
Can i have a MySQL query which checks the table containing a list of
names?

I might have the following names on the table
Sony
Compaq
Logitech
Cabinet
Fedora
Angel
Incident

Can i get the results using the query for sounds like??

select name from table where name sounds like "sonny"

This should pick up Sony.. and a query like

select name from table where name sounds like "Kompaq"

This should pick up Compaq.

This is possible in MSSQL and Oracle. Is it possible in MySQL?

Trim A String
I have a MYSQL database which has a student name, year and register number(rno) fields.

In this rno filed length is 8 characters

I use PHP with this query
$result="select * from $tabname where RNO like '%$rno%'"

My problem is, I have some hundred candidates whose register number length is only 4
The regular length is 8 eg. 56001234

Some have like this 1034

Index By END Of String
for example, if you have a list of email addresses, searching for
something like '%@yahoo.com' would need to do a full table scan.

why doesn't mysql offer a feature where it indexes by the END of the
string, so we can do these types of searches efficiently?

an index for email addresses of length 3 would only contain the last 3
chars, but it would still be a useful index type.

Connection String
If i'm right, all MySql databases are stored in some subfolders under InstallDir/Data...
This folder can be set using some configuration parameters like 'Datadir' or something like this.

Well, i want to connect to some database stored in some folder outside this one. For example i want to manage one database in drive D:myDatadata1 and a second one stored in drive F:somedatamyDatadata123.

Using Interbase i write my ConnectionString in this way:
'..... DatabaseName=192.168.1.60:C:staffibITI.gdb....'
In MySql this does not work|

Is it possible to connect to a database outside the 'Datadir' settings?

Backslash In A String
backslash is usually used as an escape marker in a string. but when I need the backslash as a real backslash, for example in paths, how can I write them?

Connection String
I am using the following code in Access 2k to establich a connection to a
MYSQL database

Dim conn As ADODB.Connection

Set conn = New ADODB.Connection

conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};DESC=;USER=" &
myUsername_
& ";DATABASE=" & mySQLDatabase_
& ";SERVER=" & myServer_
& ";PASSWORD=" & myPassword_
& ";PORT=;OPTION=;STMT=;" ';TABLE=" & myTable
conn.Open

I get a Catostrophic failure error on the conn.Open line.


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