mysql between Operator

MySQL between Operator is a logical operator normally used to selects values within the range , using MySQL between Operator we can specify start and end values to fetch the values in that ranges better example for between Operator is to fetch product price within specify range.suppose we a database with eCommerce product and their price , we have to display all the product between price 500 and 900 , like this circumstance using MySQL between Operator is the best choice.

Example mysql between Operator query

SELECT * FROM EProducts WHERE price BETWEEN 500 AND 900;

mysql between Operator

Drupal 8 Query to get category info

Here is the Drupal 8 Query to get category info
here category name “color_cat”

$vid = ‘color_cat’;
$parent_tid = 0;//parent id
$depth = 2; //depth upto which level you want
$load_entities = FALSE;
$cat_data= \Drupal::entityTypeManager()->getStorage(‘taxonomy_term’)->loadTree($vid,
$parent_tid, $depth, $load_entities);

$variables[‘color_cat’] = $cat_data;

add below code inside your .theme file

in .twig file you have use below twig code to display category name


  {% for key1, value in color_cat %}
                

{{ color_cat[key1]['name'] }} {% endfor %}

host is not allowed to connect to this mysql server

one of the most conman error when connecting to MySQL server is “host is not allowed to connect to this MySQL server” this because of the user don’t have right privileges to connect to this MySQL server follow below steps to connection issue in MySQL

if you have full permission in MySQL

Open Mysq-> phpmyadmin

Go to User accounts section

Create a new user and give all the privilege as shown in the below image

host is not allowed to connect to this mysql server

if you have cpanel info

Go to MySQL® Databases section

Scroll down to Add New User section

host is not allowed to connect to this mysql server 2

After Scroll down to Add User To Database section

Select table and user and Add User To Database

Click all ALL PRIVILEGES and Make Changes

host is not allowed to connect to this mysql server 3

Select all data from MySQL where date between two given dates

Here is the simple MySQL query to fetch data between given date range

See MySQL query



$f_date=$_REQUEST['f_date'];

$t_date=$_REQUEST['t_date'];

"SELECT * FROM sales WHERE  sales_invoice_date between '".date('Y-m-d',strtotime($f_date))."' and '".date('Y-m-d',strtotime($t_date))."' "

To Fetch all the sales data in the given date

"SELECT * FROM sales WHERE sales_invoice_date='".date('Y-m-d',strtotime($f_date))."'" 

To fetch Today’s Sales

SELECT * FROM sales WHERE STR_TO_DATE(sales_invoice_date , '%d-%m-%Y') = CURDATE()