when i give this sql query in my msaccess database table called warehouse1 it gives this error
"operation must use an updateable query?"
UPDATE warehouse1 SET STD_MOU = "?"
WHERE warehouse1.[STD_MOU]="null";
what could be the reason ?
Alternative interpretations of the SQL given:
As posted: find the fields with the literal word "null" in them and replace them all with the literal question mark.
Ask the user for the value they want to replace all Nulls with: UPDATE warehouse1 SET STD_MOU = [?] WHERE warehouse1.[STD_MOU] Is Null;
Ask the user for the value they want to replace the word "null" with: UPDATE warehouse1 SET STD_MOU = [?] WHERE warehouse1.[STD_MOU]="null";
I don't find any of these to be particularly advisable. This would be OK, though:
UPDATE warehouse1 SET STD_MOU = Null
WHERE warehouse1.[STD_MOU]="null";
Nulls are good and shouldn't be avoided at all.
Related
I have a table in BigQuery with a typo:
id,typo_column
1,Unknown
2,Unknown
3,Uknown
I want to replace Uknown by Unknown. Is there an easy way to do this in BigQuery?
You would normally do this as:
UPDATE yourproject.yourdatabase.yourtablewithtypo
SET typo_column = 'Unknown'
WHERE typo_column = 'Uknown';
There is no need to update every row in the table. There is no need to use regular expressions, and there is no need to run logic for replacement on rows that don't have the incorrect value.
You can use DML to fix all entries with typos:
UPDATE yourproject.yourdatabase.yourtablewithtypo
SET typo_column = REGEXP_REPLACE(typo_column, r"(Uknown)", "Unknown")
WHERE TRUE
See the docs for a more complete example.
I have a set of json format stored in a column and now i need to replace a particular word. How to use the replace query. Every time i use it, i'm getting token exception. please advise. Its a DB2 i'm using
I have 3 columns
Name Age Data
ABD 15 [{"Name":"ABC","type":"Regular","Math":18}]
In the Data column, I need to do a replace for "type", It should be StudentType.
REPLACE(Data,'type','StudentType');
This did not work. How to do it?
Thanks much in advance
Just like #mustaccio pointed out, if you use REPLACE in select statement it will just return your data with 'StudentType' instead of 'type'. This does not actually change data in your database. If you want to update your data you need UPDATE statement
UPDATE MyTable
SET MyColumn = REPLACE(MyColumn,'OldString','NewString')
I'm receiving the error
An expression of non-boolean type specified in a context where a condition is expected, near 'location'
when running this query:
UPDATE dbo.table
SET name = 'Matt'
WHERE date = '2013-11-23'
AND time = '12:57'
AND location = 'London'
If I modify the query to remove any one of the ANDs the query works.
Two questions:
Is it not possible to have more than one AND in the WHERE condition for an UPDATE?
How do I structure the query to make it work?
Thanks
It could be the use of reserved words like time and date. Try putting [] around those names and see if it works. And more importantly, you should use better names for your columns instead of those reserved words.
I want to Select a column and set it equal to 0. In SQL I just do this: SELECT Dealer_Fee = 0.
Do I have to use an update? When I try the same thing in Oracle I get "FROM keyword not found where expected."
I am not sure what do you want to do and in which SQL dialect the construction you mentioned works. If you just want to retrieve some value and place it in a named column in Oracle you have to use DUAL table. Try this:
SELECT 0 AS dealer_fee FROM dual;
On the other hand, if you ment T-SQL and placing a value into variable you need to use PL/SQL SELECT INTO clause, like that:
SELECT 0 INTO dealer_fee from dual;
If not try to explain in more detail what are you trying to achieve.
1) In Oracle you must specify FROM clause within SELECT, is not like MS sqlserver where you can omit a FROM clause.
2) If you want to update one specific value, you must use UPDATE clause instead SELECT.
hth
You should use the Update statement. Please visit this oracle reference which explains the Update statement in detail: Update Statement
Take a look at the reference for UPDATE in Oracle:
UPDATE <table_name>
SET <column_name> = <value>
I get an error when i try to do this using SQL. ftp.server is the key whose value i would like to change:
UPDATE OL_PREF SET ftp.server='dev.isinet.com'
If the column name is really ftp.server, then the correct Oracle syntax for updating it should be
UPDATE OL_PREF SET "ftp.server" ='dev.isinet.com'
In Oracle, double quotes are the correct way to handle column names that have non-standard characters, including lower-case letters and the period. Note that you must have the exact correct column name for this to work, including case.
You can verify the column name with:
SELECT column_name FROM user_tab_columns WHERE table_name='OL_PREF' ORDER BY column_name;
If what you really mean is that you have a table that stores key-value pairs, and that 'ftp.server' is a key, then you probably want an update like the one in Mark Wilkins' answer.
UPDATE OL_PREF SET [ftp.server]='dev.isinet.com'
or
UPDATE OL_PREF SET [ftp].[server]='dev.isinet.com'
if ftp is a schema and server is the fieldname.
You can't put the column name in quotes.
You could use brackets, which have the same functionality as quotes.
UPDATE OL_PREF SET [ftp.server] ='dev.isinet.com'
Also, it's a good idea to use "two part naming", specifying the schema as well:
UPDATE dbo.OL_PREF SET [ftp.server] ='dev.isinet.com'
UPDATE OL_PREF
SET ftp.server ='dev.isinet.com'
no '' for column names
SQL Update
'ftp.server' is in quotes. (and that should not be)
Are you getting the error ORA-00904 string : invalid identifier?
If so read this
I did a quick test on this
SQL> create table t_tab_1 ( tname varchar2(3), "ftp.service" varchar2(20) );
Table created.
SQL> insert into t_tab_1(tname,"ftp.service") values('21','ftp://fila');
1 row created.
SQL> update t_tab_1 set "ftp.service"='fila.real.com';
1 row updated.
If there is more than I row in your table remember to use the where clause in your update statement.