To insert a single quotes in a table using query - mysql

I want to insert single quotes with the data in which I am trying to insert it in a mysql table
Example id column
1 data='rose'
data='rose' should be saved under column
My Actual query is UPDATE test SET ItemType ='doctype="\'text'\"'WHERE ITEMINDEX='221'

Thanks.The following code solved my issue
UPDATE test SET ItemType ='doctype=''text''' WHERE ITEMINDEX='221'

Related

Insert json_encode of any emoji to mysql

I am trying to insert emojis into my SQL table. I have some emojis already inserted in my rows from my table, like these one: ⚽(\u26bd), ⭐(\u2b50) and ⛔ (\u26d4).
I have already tried to insert and update my rows from my table with different emojis, but i can't. I have discovered the reason that MySQL has allow me to insert the other 3 emojis and it's because the codification of they only have one \. If i try to insert a different emoji which the ascii codification has more than \, the information in the row will magically disappear, or it will be replaced with ????.
This is my query to update the one row from my table to add an emoji:
UPDATE myusers SET name = "\u26bd William" WHERE id = 8
If i run the query in my table it will insert in the row name \u26bd William, as i want.
But if i try with a different emoji which ascii codification it's like this 🚀(\ud83d\ude80)
UPDATE myusers SET name = "\ud83d\ude80 William" WHERE id = 8
The query in my table it will insert in the row name ud83dude80William, or ????William, or null. So in this time i have lost information in my row running that query
I have already tried to change the charset of my table, but it didn't make a difference
Finally to fix this issue (reffer to Akina answer, thanks very much) we have to add in the query double backslash.
Example:
UPDATE myusers SET name = "\\ud83d\\ude80 William" WHERE id = 8;
SELECT * FROM myusers;

how to update the column of one table while using the value from column of another table when using insert into statement in vba

I have googled related to "Insert into..." query, but i never find solution related to my problem.
MY query is i want to insert the value from one table to another meanwhile i also have to update the value of one additional column in table1(CBWCFARTGSADJ) using the value of table2(CBWCFAMISUPLOAD).
I have following access query:
Insert INTO CBWCFARTGSADJ (VENDOR,AMOUNT,LOCATION,DEPSLIPNO,CLIENTCODE,REMARK,transaction_type)
select
VENDOR,ADJ_AMT,LOCATION,DEPT_SLIP_NO,CLIENT_CODE,REMARKS from CBWCFAMISUPLOAD WHERE nz([ADJ_AMT],'')<>'' and nz([ADJ_AMT],'')<>'0'
here Im inserting value from CBWCFAMISUPLOAD but i want to update one additional column ie(transaction_type from table CBWCFARTGSADJ)
from ADJ_AMT column from CBWCFAMISUPLOAD
ie if ADJ_AMT >0 then transaction_type will="cr" else transaction_type of
CBWCFARTGSADJ will "DR"
please help me out... thanks in advance!!!!!

insert multiple ID in mysql row

Is it possible to insert multiple data in a single mysql row?
Example of multiple id:
41,32,31,293,877
Yes it is possible to insert the multiple values at a time in mysql database.
suppose you have created a table of name emp. and in this table you have 1 field which is named as id.
now you just want to insert the multiple id in a table named emp , so can do this by writing following command ->
INSERT INTO emp(id) VALUES(1),(2),(3),(4),(5),(6);
Above query will insert the following given values in a table.
If you declare column to be VARCHAR().
yes you can insert multiple IDs. like
INSERT INTO table (Id) value ('41,32,31,293,877');
If you are using varchar or text data type for Id field then it is possible to enter and store with comma separated.
INSERT INTO TABLENAME (Id) VALUES ('41,32,31,293,877');
If you are inserting into a single table, you can write your query like this :
insert into table (id) values (41),(32),(31),(293),(877);

How to insert * symbol in mysql using php

i have one field which contain data like 4563******3245. when i execute my sql query it is inserted successfully. but in mysql database it is showing only 4563
my sql query is:
insert into mytable ('myfield') values ('4563******3245');
Can any one tell me where is the problem.
thank you.
insert into mytable ('myfield') values ('4563******3245');
it is working fine
make sure your column type should be varchar
You can't store text in a column of a number data type. You have to change your data type to char(14).
ALTER TABLE your_table MODIFY myfield CHAR(14);
If your running that particular query, and only 4563 is being inserted, it would suggest your column type for "myfield" is set as some variant or length of "int" rather than char(22) (CCN's are not always 16 digits, some can be 20 or 22).
you should probably switch the column type to make sure the data inserts correctly to something like
ALTER TABLE mytable MODIFY myfield char(22);

Access Auto-Increment Value During INSERT INTO Statement

I am currently using MySQL. I have a table that has an auto_increment 'id' field, and an 'imgname' field containing a string that is the file name of an image.
I need to generate the 'imgname' value using the auto_increment value that is create by an INSERT INTO statement. The problem is, I don't know this value until I can use mysql_insert_id, AFTER the insert query has run. I would like to know if it's possible to access this value DURING the insert query somehow and then use it to generate my string in the query statement.
Thanks in advance.
I would keep the id and imgname independent of each other and combine the two on SELECT when needed. If the need is frequent enough, create a view.
Have a look at LAST_INSERT_ID() function. If performance is not an issue, INSERT regularly, and then UPDATE using LAST_INSERT_ID(), like:
UPDATE table SET name = CONCAT(name, "-", LAST_INSERT_ID()) WHERE id = LAST_INSERT_ID();