Chandu yadav has Published 1163 Articles

MySQL truncate text with ellipsis?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

887 Views

You can truncate the text with ellipsis using LENGTH() with CASE statement. If your length is greater than 7 then truncate the text and add some number otherwise print the number as it is.To understand the above syntax, let us create a table. The query to create a table is ... Read More

How to change package name in android?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

231 Views

Here are the simple steps to change the package name in android .Click on your pack name(in source tree). -> Right Click --> Refractor -> Rename as shown below -Click on rename, it will show pop up as shown below -Click on Rename package, it will show new pop up ... Read More

Generate table DDL via a query on MySQL and SQL Server?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

12K+ Views

The DDL stands for Data Definition Language. To generate the table DDL via query, you can use show create command.The syntax is as followsSHOW CREATE TABLE yourTableName;The above syntax is MySQL specific. Suppose, we have a table with the name ‘DDLOfTableStudent’.First, create a table with the name ‘DDLOfTableStudent’. The query ... Read More

Use a trigger to stop an insert or update in MySQL?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

4K+ Views

You need to use SIGNAL SQL STATE command to stop an insert or update in MySQL. The trigger syntax is as follows:DELIMITER // CREATE TRIGGER yourTriggerName BEFORE INSERT ON yourTableName FOR EACH ROW BEGIN yourCondition THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'anyMessageToEndUser'; END // DELIMITER ;Now, create a trigger ... Read More

MySQL String Last Index Of in a URL?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

602 Views

To get the last index, use the SUBSTRING_INDEX() function from MySQL. The syntax is as follows −SELECT yourColumnName1, ...N, SUBSTRING_INDEX(yourColumnName, ’yourDelimiter’, -1)as anyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table LastIndexString    -> (   ... Read More

How to sort Strings on an Android RecyclerView?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

2K+ Views

Before getting into Sort array list elements for recycler view example, we should know, what is Recycler view in android. Recycler view is a more advanced version of the list view and it works based on View holder design pattern. Using recycler view we can show grids and list of ... Read More

MySQL: Insert a row and get the content?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

97 Views

In order to do insert a row and get the content, you need to use stored procedure, First, you need to create a table. After that you need to create a stored procedure that will insert a row and get the content to the end user.To do the above task, ... Read More

How to declare a variable in MySQL for a normal query?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

3K+ Views

You can declare a variable using @anyVariablename which is a session variable. To create a session variable, you need to use SET command.The syntax is as followsSET @anyVariableName:=anyValue;You can declare a local variable using DECLARE command. The syntax is as followsDECLARE yourVariableName datatypeYou can set the default value at the ... Read More

How to specify Decimal Precision and scale number in MySQL database using PHPMyAdmin?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

2K+ Views

You need to select a database when you are creating a table. Right now, I have a sample database. The snapshot is as follows:Now you need to give the table name as well as the number of columns you want:After that you need to press Go button. Now, the following ... Read More

Find max and second max salary for a MySQL Employee table using subquery?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

173 Views

You can get max and second max salary from an Employee table using subquery.Let us first create a table. The query to create a table is as follows −mysql> create table EmployeeMaxAndSecondMaxSalary    -> (    -> EmployeeId int,    -> Employeename varchar(20),    -> EmployeeSalary int    -> ); ... Read More

Advertisements