Signup/Sign In

Answers

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

The basic difference between *Join* and *Inner join* is that Microsoft Access does not allow just *join* but it requires *inner join*.
Inner specifies all matching pairs of rows get returned. When join type is not specified, this is the default.
However, both are equivalent functionally but *inner join* is a bit clearer to read more specifically if the query has other join types included in it like LEFT, RIGHT or CROSS.
4 years ago
You can use the following code to list all the tables in the Oracle database-
***sql> SELECT table_name
FROM dba_tables;***
In order to get all the table names, you may also use-
**Select owner, table_name from all_tables;**
This will list only the required data instead of extra data that confuses you.
4 years ago
The answer is yes. Python has a ternary conditional operator. It allows testing a condition in a single line by replacing the multiline if-else which makes the code compact. The syntax is-
***[on_true] if [expression]
else [on_false]***
A simple way of using the ternary operator is as follows-
***a, b = 10, 20
min = a if a < b else b
print(min)***
Here the output will be 10.
Another way of using a ternary operator is by using *nested if-else*-
***a, b = 10, 20
print ("Both a and b are equal" if a ==b else "a is greater than b"
if a > b else "b is greater than a")***
4 years ago
One of the best ways of removing duplicates is by using the *set()* function in python, and then converting it back into list. The code is as follows-
***In [2]: some_list = ['a', 'a', 'v', 'v', 'v', 'c', 'c', 'd']
In [3]: list(set(some_list))
Out [3]: ['a', 'c', 'd', 'v']***
Simplifying it,
**mylist = list(set(mylist))**
You may also use the iterator to remove the duplicates-
***def uniqify(iterable):
seen = set()
for item in iterable:
if item not in seen:
seen.add(item)
yield item***
This will return an iterator or generator so that you may use it wherever you can use an iterator.
For list:
***unique_list = list(uniqify([1, 2, 3, 4, 3, 2, 4, 5, 6, 7, 6, 8, 8]))
print(unique_list)***
4 years ago
There are several ways of creating ArrayList from array in Java-
Suppose we have- ***Element[]
array = { new Element(1),
new Element(2), new Element(3)};***, hence, the ArrayList can be created as follows-
***ArrayList arraylist_1 = new ArrayList<>(Arrays.asList(array));
ArrayList arraylist_2 = new ArrayList<> (Arrays.asList(new Element[] {new Element(1), new Element(2), new Element(3) }));
ArrayList arraylist_3 = new ArrayList<>();
Collections.addAll(arraylist_3, array);***
You may go for one of the simplest ways which is as follows:
***String[] Array={"one", "two", "three"};
ArrayList s1 = new ArrayList(Arrays.asList(Array1));***
4 years ago
For ArrayList initialization equivalent to array initialization, the following code may be used as answer-
***ArrayList
(Arrays.asList(1, 2, 3, 5, 8, 13, 21));***
But it is important to understand what is this code all about?
Firstly, the elements are copied into the **Arrays.ArrayList** which gets created by a static factory **Arrays.asList(T..)**. But it does not produce the same class as the **java. lang.ArrayList** although it has the same class name. Now, the **Arrays.ArrayList** which was constructed by us is passed to the constructer- ***ArrayList<>
(Collection***. Now, the constructer decides whether to copy it again for removing the subclass type. - **Arrays.asList(T..)** where it internally uses an array of type T.
4 years ago
In order to horizontally centre an element, you first need to ensure that the parent element is positioned as relative, fixed, sticky or absolute. The code is as follows-
***.centered {
position: absolute;
left: 50%;
margin-left: -100px;
}***
In this case, the width of your element or div is 200 pixels.
In case you do not know the width of your element or div, then you can use the following code instead of a negative margin-
**transform: translateX (-50%);**
And by using CSS calc() property, it gets even simpler:
***.centered {
width: 200px;
position: absolute;
left: calc (50% - 100px);
}***
4 years ago
You can reset the *AUTO_INCREMENT* of a field in MySQL using the code-
**ALTER TABLE tablename AUTO_INCREMENT = value**
There is one more way to reset the AUTO_INCREMENT with PHPMyAdmin under the tab name 'operations' and then you can easily set the autoincrement to the value you want, in the 'table' option.
And it is to be noted that you are not allowed to reset the counter to any value less than or equal to any value that has been already used.
There is a short example:
***ALTER TABLE my_table MODIFY COLUMN ID INT (10) UNSIGNED;
COMMIT;
ALTER TABLE my_table MODIFY COLUMN ID INT (10) UNSIGNED AUTO_INCREMENT;
COMMIT;***
With this, the auto-increment counter gets reset and will start automatically from the maximum value that exists.
4 years ago
There are several types of joins in SQL which are slightly different from each other-
*INNER JOIN*-This join returns the rows when there happens to be a match of the rows in both tables.
*LEFT JOIN*- This join returns all the rows from the left table despite the fact whether there are any matches in the right table or not.
*RIGHT JOIN*- This join returns all the rows from the right table despite the fact whether there are any matches in the left table or not.
*FULL JOIN*- This join is used to combine the results of both the right and left outer joins where the joined table will be containing all records from both the tables and fills in 'NULL' for all the missing matches on either side.
4 years ago
Although both *require* and *include* are ways to include files, but there is a major difference between *require* and *include*. While *require* means that it has its requirement or needs it, it has to be there whereas *include* means it is going to include a file but it is not necessary as a requirement. *Require_once* means that it requires it only once whereas *include_once* means that it will include a file but only once. There is a short example showing how to write these functions:
***require 'filename'
require_once 'filename'
include 'filename'
include_once 'filename'***
4 years ago