How to column value shows null or 0 with id wise - mysql-error-1064

Hi i am beginner of PHP i have query how to show column value show null or zero with id i try below query but this are delete my all bigimage2 in product5 (table name)
mysql_query("UPDATE product5 SET bigimage2 = NULL WHERE bigimage2 = 0");
want insert column shows null with respective row id
above query is run properly but they shows all id in product5 shows null i want selected id column value is null not all id

Please put the unique I'd on where condition not other. Because Run time update only one record not many.
Example : Update table set field= value where id=id value

Related

ORACLE SQL Replace null values with previous value depending on other fields

From a query I want to replace the null values of the "cod_account" field, the condition to fill this field is that it must take the previous value only if it satisfies that the previous records of other fields (cod_agen, cod_sub, no_prod) are equal.
Currently it is like this:
enter image description here
what is desired is
enter image description here
thanks for your advice. i solve it
use with to separate queries.
select
case when cod_account is null and class ='Primary'
then null
when cod_account is null and class='Secundary'
then (select cod_account from principals P--principals is table create in a "with"
where fa.cod_agen=P.cod_agen
and fa.cod_sub=P.cod_sub
and fa.no_prod=P.no_prod
and p.class='secundary'
)
...
from signs fa

Select row from table where same value in another column for every row

I want to find all IDs in a table where 'FALSE' is the value in another column for every row with that ID. In the screen cap here:
I only want to get back 'AFERRIERA' and 'AHANLON' because for every row that is in the column IDENTITY the column "METHOD_DEFAULT' is 'FALSE'
It's OK I resolved it:
SELECT DISTINCT IDENTITY
FROM PERSON_INFO_COMM_METHOD2 t
WHERE METHOD_DEFAULT = 'FALSE'
AND NOT EXISTS (SELECT * FROM PERSON_INFO_COMM_METHOD2 WHERE METHOD_DEFAULT <> 'FALSE'
AND IDENTITY = t.IDENTITY)

Need query to ALTER more rows in one column without WHERE constrain

I am looking for a query which I can use in pymysql to UPDATE the rows in one column without the WHERE constraint.
This is the query I used but it replaces all the NULL into 1s:
UPDATE simplefocusstatistic_studentanswers
SET Player_id = null WHERE simplefocusstatistic_id = 1

select value form one table update value for fetched value in single query

I have two tables request and details.request table id is foreign key for details table I want I have price(321) and request_id(1819AM002) value.I want to fetch value id using request_id in request table update price field value in details table in single query.Is it possible to achieve in single query
request table
id request_id name type
1 1819AM001 XXX A
2 1819AM002 YYY A
Details table
id request_id price
1 2 133
Try this:
DB::table('details')
->join('request', 'details.request_id', 'request.id')
->where('request.request_id', '1819AM002')
->update(['price' => 321]);

date Not null , error ora_01758

why I am getting this error ?
In the table DDL I only have 2 columns , id (number) and name (varchar)
ALTER TABLE mytable ADD SUSPEND date NOT NULL
ORA-01758: table must be empty to add mandatory (NOT NULL) column
ORA-06512: at line 7
ORA-01758: table must be empty to add mandatory (NOT NULL) column ORA-06512: at line 7
And is your table empty? I think not.
There's probably a way around this involving adding the column as nullable, then populating every row with a non-NULL value, the altering the column to be not null.
Alternatively, since the problem is that these current rows will be given NULL as a default value, and the column is not allowed to be NULL, you can also get around it with a default value. From the Oracle docs:
However, a column with a NOT NULL constraint can be added to an existing table if you give a default value; otherwise, an exception is thrown when the ALTER TABLE statement is executed.
Here is a fiddle, how you could do it
Would a date in the future be acceptable as a temporary default? If so, this would work:
ALTER TABLE MYTABLE ADD (SUSPEND_DATE DATE DEFAULT(TO_DATE('21000101', 'YYYYMMDD'))
CONSTRAINT SUSPEND_DATE_NOT_NULL NOT NULL);
If table already contain the records then table won't allowes to add "Not null" column.
If you need same then set default value for the column or truncate the table then try.

Resources