AmitDiwan has Published 10744 Articles

Sum columns corresponding values according to similar dates in MySQL?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:31:06

214 Views

For this, use aggregate function SUM() along with GROUP BY. Let us first create a table −mysql> create table DemoTable1522    -> (    -> ProductPurchaseDate date,    -> NumberOfProduct int    -> ); Query OK, 0 rows affected (1.51 sec)Insert some records in the table using insert command −mysql> ... Read More

Convert Class in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:29:45

718 Views

The Convert Class has methods to convert a base data type to another base data type. Let us see some examples −The Convert.ToBoolean() method in C# is used to convert a specified value to an equivalent Boolean value.SyntaxFollowing is the syntax −public static bool ToBoolean (string val, IFormatProvider provider);Above, Val ... Read More

Update a column in MySQL and remove the trailing underscore values

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:27:28

551 Views

To remove the trailing values, use TRIM() as in the below update syntax −update yourTableName set yourColumnName=trim(trailing '_' from yourColumnName);Let us first create a table −mysql> create table DemoTable1521    -> (    -> StudentCode varchar(20)    -> ); Query OK, 0 rows affected (1.33 sec)Insert some records in the ... Read More

Char Struct in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:26:39

410 Views

The Char Struct in C# represents a character as a UTF-16 code unit. Here are some of the methods −MethodDescriptionConvertToUtf32(Char, Char)Converts the value of a UTF-16 encoded surrogate pair into a Unicode code point.ConvertToUtf32(String, Int32)Converts the value of a UTF-16 encoded character or surrogate pair at a specified position in ... Read More

Take all records from one MySQL table and insert it to another?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:25:16

177 Views

For this, you can use the concept of CREATE TABLE AS SELECT statement. Let us first create a table −mysql> create table DemoTable1518    -> (    -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> EmployeeName varchar(20)    -> )AUTO_INCREMENT=101; Query OK, 0 rows affected (0.69 sec)Insert some ... Read More

Getting the Standard Output and Standard Error Output Stream through Console in C#

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:24:33

646 Views

To get the standard output stream through Console, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(string[] args){       Console.WriteLine("Standard Output Stream = "+Console.Out);    } }OutputThis will produce the following output −Standard Output Stream = System.IO.TextWriter+SyncTextWriterExampleTo get the standard ... Read More

How do I select data from one table only where column values from that table match the column values of another table in MySQL?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:23:25

4K+ Views

For this, you can use subquery along with EXISTS. Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int,    -> SubjectName varchar(20)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert ... Read More

Counting with condition in MySQL?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:19:44

981 Views

To count, use aggregate function SUM() and to count with condition, you need to set the condition with WHERE. Let us first create a table −mysql> create table DemoTable1515    -> (    -> ClientId varchar(10),    -> ClientName varchar(20)    -> ); Query OK, 0 rows affected (0.53 sec)Insert ... Read More

MySQL query to select rows one batch at a time

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:15:48

3K+ Views

For this, you can use the concept of LIMIT and OFFSET. Let us first create a table −mysql> create table DemoTable1514    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> FirstName varchar(20)    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in ... Read More

When inserting a new row, should I include the columns that are null in the MySQL query?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2019 06:14:44

143 Views

If you do not specify the column list in insert statement then you can use below syntax −insert into yourTableName values(NULL, yourValue, NULL, NULL, .....N);Let us first create a table −mysql> create table DemoTable1513    -> (    -> StudentId int,    -> StudentName varchar(20) ,    -> StudentAge int, ... Read More

Advertisements