Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

The basic syntax rule goes without specifying the columns in the *INSERT INTO* part in case you are supplying values for all the columns in the *SELECT* part. The code is as follows-
***INSERT INTO table1
SELECT col1, col2
FROM table2***
But this will not work since the value for col2 is not specified.
Now, by using the MS SQL server,
***INSERT INTO table1
SELECT col1
FROM table2***
4 years ago
The code for listing the tables in an SQLite database is as follows-
**.tables ?PATTERN? List names of tables matching a LIKE pattern**
Now, this code converts to the following SQL-
***SELECT name FROM sqlite_master
WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%'
UNION ALL
SELECT name FROM sqlite_temp_master
WHERE type IN ('table','view')
ORDER BY 1***
Or you may also use this code-
***SELECT name FROM sqlite_master
WHERE type='table';***
4 years ago
The code for changing scheme name in the MYSQL database is as follows-
***mysqladmin create new_db_name
mysqldump db_name | mysql new_db_name***
You need to first export the database to file and then import it again in the workbench you may specify the name of the db there. Then in the workbench, gpo to the server tab and then select 'data export'.
4 years ago
The code for finding all the files is as follows-
**find/-type f-exec grep -H 'text-to-find-here' {}\;**
In this case, *find* is the standard tool for searching all files which are combined with grep when you look for a specific text on platforms like Unix. This command is usually combined with xarqs.
The other way is by using 'pwd' to search from any directory you are moving in. The code is as follows-
**grep- rnw 'pwd' -e"pattern"**
4 years ago
If you wish to get all tables in MS SQL, the code is as follows-
***SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME like '%'
and TABLE_SCHEMA = 'tresbu_lk'***
And if you wish to get all tables with specific column names in MS SQL, then go for the following code-
***SELECT DISTINCT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name LIKE '%'
AND TABLE_SCHEMA='tresbu_lk'***
You may use this query code to replace the desired column name by your own column name-
**SELECT TABLE_NAME FROM information_schema.columns WHERE column_name = 'desired_column_name';**
4 years ago
The difference between UNION and UNION ALL is that UNION is known for removing duplicates while UNION ALL does not do that. For removing the duplicates, the result set should be first sorted and this might have an impact on the performance of UNION on the basis of the volume of data that is being sorted and also the settings of several RDBMS parameters. The sorting process is faster if it is carried out in memory but the same caution about the volume of data applies.
In case you need data to be returned without any duplicate, then you need to use UNION on the basis of the source of your data.
UNION does not support BLOB or CLOB column types in Oracle but UNION ALL does support. Like for example,
**SELECT * FROM mytable WHERE a=X UNION ALL SELECT * FROM mytable WHERE b=Y AND a!=X**
where AND a! = X part. This is faster than UNION.
4 years ago
The context class in Android is known as an *interface to global information about a certain application environment*.
It is declared as an abstract class where implementation is offered by the Android Operating System. Context allows access to the application-specific resources and classes and up-calls for the application-level operations like launching activities, receiving intents, broadcasting, etc. Here is an example in which the abstract method getAssets is implemented from the Context class as follows-
***@Override
public AssetManager getAssets() {
return mBase.getAssets();
}***
where 'mBase' is a fieldset by the constructor to a certain context.
There are several ways of getting context-
***getContext()
getBaseContext()
getApplicationContext()
this***
4 years ago
One of the easiest methods for closing the Android soft keyboard programmatically is to just call the hide keyboard from Your Activity. this to hide the keyboard. The code is as follows:
***public static void hideKeyboardFrom(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}***
For Open keyboard, the code is as follows:
***InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(edtView, InputMethodManager.SHOW_IMPLICIT);***
For Close keyboard, the code is as follows:
*** InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edtView.getWindowToken(), 0);***
4 years ago
In order to create a singly linked list, you should not incrtement head after 'head = head-> next' in the for loop otheriwse the printlist returns NULL each time as the loop will not stop until and unless the 'head' is NULL. You may use the code-
***LIST *current = head;
while (current != NULL) {
printf("%s %d", current->str, current->count);
current = current->next;
}***
You need to remember that the second malloc allocates memory but the return value for it is not assigned to anything so that the allocated memory gets lost. A *newList* is allocated but is not initialized. So using a *memcpy* for copying memory to *newList* ->str fails since newList ->str points to nothing.
4 years ago
As per the Topaco notes, the part just after the *UKC19TRACING:1:* is a *JWT*. This is a QR code. You can easily decode it using the following code-
Header
***{
"alg": "ES256",
"kid": "YrqeLTq8z-ofH5nzlaSGnYRfB9bu9yPlWYU_2b6qXOQ"
}***
This lets us know how it is signed and also the identifier of the key that has signed it.
For Payload-
***{
"id": "V5VWX39R",
"opn": "Pipley Barn Café",
"adr": "Pipley Barn\nBrockham End\nLansdown",
"pc": "BA19BZ",
"vt": "008"
}***
This is the signed payload. This is not encrypted. It is b64-encoded and signed with the header.
4 years ago
'Item' is a string in our code. The string indices are the characters inside the square brackets. First you must check your data variable to see what you receive.
For example, the following code shows an error-
***>>> my_string = "hello world"
>>> my_string[0,5]***
'TypeError:' string indices should be integers. We passed a tuple of two integers implicitly here, from 0 to 5 to the slice notation where we called 'my_string[0,5] as 0,5 evaluates to the same tuple as (0,5) does. We need to replace the comma with a colon in order to separate two integers correctly-
Like here, the code goes as-
***>>> my_string = "hello world"
>>> my_string[0:5]
'hello'***
4 years ago
In case your error is-
**ERROR 1698 (28000): Access denied for user 'root'@'localhost'**
Then, it can be solved by the following code-
**sudo mysql -u root -p mysql**
You do not have to restart MySQL, instead, use the following-
***sudo mysql
-- for MySQL
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
-- for MariaDB
ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password USING PASSWORD('root');***
In this case, we are changing the auth_plugin to mysql_native_password with only a single query. And we are setting the password to root.
4 years ago