mysql colomn value in other column with extra value - mysql

In my table in mysql, I have 4 columns, but I added one extra column. And the value of the last column must be the value of column 1 with extra value.
for example:
UPDATE users SET user = 'column_1_value'."00";
It's like merging column value with extra value.
Thanks inadvance !

since you did not provide enough context like the datatypes your table consists of I can just guess. If they are string types (like varchar) you can use concat:
UPDATE users SET column_4 = CONCAT(column_1, "00");

Related

What to assign for MySQL column that must not be empty?

I have a MySQL table named customers. In this table, there is a column called fullname that must not be empty when a new row is created. Is it right to assign a Not Null attribute to this column to imply that the column cannot be empty?
It a word - yes. If a column may not be empty, it should be defined as not null.

SELECT all COLUMN_NAMES from a table that have a specific entry

I have a table with 21 columns and I need to find all column names that have a specific value in them. This goes beyond my knowledge of database querying.
If this is possible, how would I do this?
Do you need to find columns in which the name of the column contains a certain value or there exists a row in which the given column contains the given value?
In the first case you could try the show columns: http://dev.mysql.com/doc/refman/5.0/en/show-columns.html

How to check each row in a table for at least one null or constant value in SSIS?

I have a table with 20 fields.
1) Is there any way to check all fields if any of them are NULL?
2) For all columns that are nvarchar i want to search if they contain a constant string value e.g. "Missing".
Can i do the above in SSIS without having to check the columns one by one?
There is no Null-inator that would check if any column is null in a row. However, you could concatenate all the columns in the row and if any column is null then the result will be null. So in a derived column task it could look like this:
Field1 + Field2 + (DT_WSTR, 50)Field3...
As demonstrated in field3, all fields that are not string would need to converted.
Similarly, you can find a keyword, like "missing" by concatenating all the fields in a derived column task and using FINDSTRING(). That could looks like this:
FINDSTRING(Field1 + Field2, "Missing",1)
If the value is greater than 0, you have a hit. There a drawbacks though. Given that your columns are nullable, you would need null handling on all the columns unless this test was only performed on rows where there are no nulls. Also, it doesn't tell you which column has the value, so that probably is not very useful unless you are rejecting or quarantining the entire row.

how to set one field in a table equal to another field in a table in access

I have a table with two fields, IDCopy and ID. I want to copy the value of ID into IDCopy because ID is a number field and I need a second copy of this field as a text field.
I am used to doing things like this on sql server
UPDATE table SET table.IDCopy= table.ID;
But when I try to run that query in access it asks me for the parameter value of ID. What is the syntax for setting one column in a table to another column in Access?
You can use CStr() to cast the ID number to text. This should work when IDCopy is text and ID is numeric.
UPDATE [table] SET IDCopy = CStr(ID);
I bracketed the table name because table is a reserved word.
If Access still thinks ID is a parameter with this query, then [table] does not include a field named ID.

Update a MySQL table that has only one row with no id column

I have a MySQL table called settings. It has multiple columns, where every column is an item with a single value. So it has only one row and no id column. The design is final (I don't plan to add more columns).
How can I update the value in a single column (change one setting's value)?
What's the problem with using this --> http://dev.mysql.com/doc/refman/5.0/en/update.html
?
UPDATE table1 SET column1 = value
In case you have more than one row, you can add:
WHERE table1.column = matching_value;
making sure the match criteria is only the row you need.
to update a value of certain item column you must specify the row contains the value to be updated, since you don't have a primary key, you can depend on the nature of item values to act as row identifier and i don't recommend that.. the best way is to update your design and add column for the primary key