I am facing issue in SQL query and need some help.
I am newbie in Php and sql. So any help would be aprreciated.
I have the following Sql query and tries.
$insert_on_duplicate_update_query = "INSERT INTO test (`store_client_id`,`customer_id`,`first_name`,`last_name`,`email`,`created_on`,`updated_on`,dob) VALUES('1','123','abc','xyz','[email protected]','2018-10-12 00:00:02','2018-10-12 00:00:02','NULL') ON DUPLICATE KEY UPDATE `store_client_id`='1',`customer_id`='123',`first_name`='abc',`last_name`='xyz',`email`='[email protected]',`updated_on`='2018-10-12 00:00:02',dob='null';";
$insert_on_duplicate_update_query = str_replace(array("'NULL'","'null'"), null, $insert_on_duplicate_update_query);
echo $insert_on_duplicate_update_query;
So here i want to replace 'NULL' to NULL in the follow place -
VALUES('1','123','abc','xyz','[email protected]','2018-10-12 00:00:02','2018-10-12 00:00:02','NULL')
Using lots of joins can slow down retrieval performance (though with proper indexing, the penalty is often a lot less than people think -- measure first). However, people tend to forget that removing the joins often means 'denormalizing' the data, which then incurs costs when the data must be modified.
Join order in SQL2008R2 server does unquestionably affect query performance, particularly in queries where there are a large number of table joins with where clauses applied against multiple tables. Although the join order is changed in optimisation, the optimiser does't try all possible join orders.
Joins: If your query joins two tables in a way that substantially increases the row count of the result set, your query is likely to be slow. There's an example of this in the subqueries lesson. Aggregations: Combining multiple rows to produce a result requires more computation than simply retrieving those rows.
Just need to change second parameter in str_replace function as bellow.
`$str = "abc = 'NULL'";
$a = str_replace("'NULL'", 'NULL', $str);
echo ($a);`
Second parameter with '' quotes.
You need to change in str_replace() function on second line.
It should be as below.
$insert_on_duplicate_update_query = str_replace(array("'NULL'","'null'"), 'null', $insert_on_duplicate_update_query);
Hope it make sense
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With