AmitDiwan has Published 10740 Articles

Limit total number of results across tables in MySQL?

AmitDiwan

AmitDiwan

Updated on 19-Nov-2020 10:48:20

205 Views

For this, you can use UNION ALL along with LIMIT concept. For our example, we will create three tables.Let us create the first table −mysql> create table demo3 −> ( −> value int −> ); Query OK, 0 rows affected (1.39 sec)Insert some records into the table with the help ... Read More

Multiple LIKE Operators with ORDER BY in MySQL?

AmitDiwan

AmitDiwan

Updated on 19-Nov-2020 10:40:51

265 Views

Following is the syntax implementing multiple LIKE operators with ORDER BY −select *from yourTableName order by (    yourColumnName like '%yourValue1%' ) + (    yourColumnName like '%yourValue2%' ) + . . N desc;Let us create a table −mysql> create table demo2 −> ( −> id int not null auto_increment, ... Read More

How to get number located at 2 places before decimal point MySQL?

AmitDiwan

AmitDiwan

Updated on 19-Nov-2020 10:37:16

229 Views

In order to get number located at 2 places before decimal point, you can use the concept of div.Let us create a table −mysql> create table demo1 −> ( −> value float −> ); Query OK, 0 rows affected (2.20 sec)Insert some records into the table with the help of ... Read More

Wrap object properties of type string with arrays - JavaScript

AmitDiwan

AmitDiwan

Updated on 09-Nov-2020 11:17:24

566 Views

For this, use Object.keys() along with reduce(). To display the result, we will also use concat().ExampleFollowing is the code −var details = { name: ["John", "David"], age1: "21", age2: "23" },    output = Object       .keys(details)       .reduce((obj, tempKey) =>          (obj[tempKey] ... Read More

Find the Sum of Radio button values jQuery?

AmitDiwan

AmitDiwan

Updated on 09-Nov-2020 11:15:35

530 Views

Let’s say we have marks records and we need to sum them. The records are displayed in Radio Button −Marks1 75 {          if (evnt.checked) {             total = total + parseInt(evnt.value);             return;     ... Read More

How to merge specific elements inside an array together - JavaScript

AmitDiwan

AmitDiwan

Updated on 09-Nov-2020 11:11:59

139 Views

Let’s say the following is our array −var values = [7, 5, 3, 8, 9, '/', 9, 5, 8, 2, '/', 3, 4, 8];To merge specific elements, use map along with split().ExampleFollowing is the code −var values = [7, 5, 3, 8, 9, '/', 9, 5, 8, 2, '/', 3, ... Read More

Get the correct century from 2-digit year date value - JavaScript?

AmitDiwan

AmitDiwan

Updated on 09-Nov-2020 11:10:40

355 Views

For this, you can use ternary operator based on some condition.ExampleFollowing is the code −const yearRangeValue = 18; const getCorrectCentury = dateValues => {    var [date, month, year] = dateValues.split("-");    var originalYear = +year > yearRangeValue ? "20" + year : "18" + year;    return new Date(date ... Read More

What is the “get” keyword before a function in a class - JavaScript?

AmitDiwan

AmitDiwan

Updated on 09-Nov-2020 11:08:56

485 Views

The get keyword can be used as a getter function like C#, Java and other technologies.We set a function with get like the following in a class −class Employee {    constructor(name) {    this.name = name;    }    get fullName() {       return this.name;    } ... Read More

Take in two 2-D arrays of numbers and returns their matrix multiplication result- JavaScript

AmitDiwan

AmitDiwan

Updated on 09-Nov-2020 11:06:59

388 Views

We are required to write a JavaScript function that takes in two 2-D arrays of numbers and returns their matrix multiplication result.Let’s say the following are our two matrices −// 5 x 4 let a = [    [1, 2, 3, 1],    [4, 5, 6, 1],    [7, 8, ... Read More

Return a splitted array of the string based on all the specified separators - JavaScript

AmitDiwan

AmitDiwan

Updated on 09-Nov-2020 11:03:56

158 Views

We are required to write a JavaScript function that takes in a string and any number of characters specified as separators. Our function should return a splitted array of the string based on all the separators specified.For example −If the string is −const str = 'rttt.trt/trfd/trtr, tr';And the separators are ... Read More

Advertisements