Get Average and Join 3 tables - mysql

I have 3 tables which are given below;
User table:
<table border="1">
<tr>
<td>uid</td>
<td>name</td>
<td>status</td>
<td>category</td>
</tr>
<tr>
<td>1</td>
<td>John Doe</td>
<td>1</td>
<td>C</td>
</tr>
<tr>
<td>2</td>
<td>Jane Doe</td>
<td>1</td>
<td>C</td>
</tr>
</table>
Profile Table:
<table border="1">
<tr>
<td>pid</td>
<td>uid</td>
<td>slug</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>john-doe</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>jane-doe</td>
</tr>
</table>
And Rating Table:
<table border="1">
<tr>
<td>rid</td>
<td>uid</td>
<td>rating</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>3.5</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>2.5</td>
</tr>
<tr>
<td>3</td>
<td>2</td>
<td>3.5</td>
</tr>
<tr>
<td>4</td>
<td>1</td>
<td>2.5</td>
</tr>
<tr>
<td>5</td>
<td>2</td>
<td>3.5</td>
</tr>
<tr>
<td>6</td>
<td>2</td>
<td>2.5</td>
</tr>
<tr>
<td>7</td>
<td>1</td>
<td>3.5</td>
</tr>
<tr>
<td>8</td>
<td>2</td>
<td>2.5</td>
</tr>
</table>
I m trying to join the table and get value having common id with avg rating from rating fromr rating table.
the output I want is given below;
<table border="1">
<tr>
<td>uid</td>
<td>name</td>
<td>slug</td>
<td>status</td>
<td>category</td>
<td>rating</td>
</tr>
<tr>
<td>1</td>
<td>John Doe</td>
<td>john-doe</td>
<td>1</td>
<td>C</td>
<td>3.25</td>
</tr>
<tr>
<td>2</td>
<td>Jane Doe</td>
<td>jane-doe</td>
<td>1</td>
<td>C</td>
<td>3</td>
</tr>
</table>

Please try below query, I think this will work for you.
select u.*, p.slug, (select avg(rating) from Rating r where r.uid=u.uid) as rating from User u JOIN Profile p ON p.uid=u.uid

Related

How to present a HTML table in multiple columns on paper?

I have an easy question, but I don't know where to start looking for a solution...
Suppose I have a large data table (more than 300 rows) in HTML, very simply in structure, I made it even simpler for this question.
<table>
<tr><td>1</td><td>AA</td><td>solved</td></tr>
<tr><td>2</td><td>AB</td><td>closed</td></tr>
<tr><td>3</td><td>AC</td><td>new</td></tr>
<tr><td>4</td><td>AD</td><td>solved</td></tr>
....
<tr><td>300</td><td>ZZ</td><td>new</td></tr>
<table>
When I print this on paper, this will take up too many pages, leaving a lot of "whitespace" unused. So I would like to divide these tablerows over 3 columns, with each column containing exactly 45 records.
So 1st column contains row 1 tot 45,
2nd column contains row 46 to 90 and
3rd column contains row 91 to 135
Then, this proces continues on page2 and so on until all records are printed in columns of 45 rows each, 3 columns on 1 page.
I would like to find a solution for this, using a CSS, so I keep all the flexibility in case I need to change these settings (i.e. printing on A5, landscape, 4 columns instead of 3, ...)
My question is : What is the easiest way to do so, and which techniques do I need to use. I already had a look at CSS flexbox, grid, Nth-children, ... but before I dive into these details, I would like to have some advise on this....
It is important to know that my only purpose is to print it on paper (no interactivity needed on screen)
So please where do I start ?
Any help appreciated.
Use below style:
#media print {.newspaper {column-count: 3;}}
JSFiddel Link:
https://jsfiddle.net/rsanimesh/Lo8up7cx/1/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
#media print {
.newspaper {
column-count: 3;
}
}
</style>
<body>
<div class="newspaper">
<table>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>6</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>7</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>8</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>9</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>10</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>11</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>12</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>13</td>
<td>ZZ</td>
<td>new</td>
</tr>
<tr>
<td>14</td>
<td>ZZ</td>
<td>new</td>
</tr>
<tr>
<td>15</td>
<td>ZZ</td>
<td>new</td>
</tr>
</table>
</div>
</body>
</html>
A possibility would be to break the table-layout into a grid and flex layout:
Example (45 columns seems a bit too much , a lot, is it not ? ) : misreading the question, see other options below
/* media commented fo visual test */
/* #media print { */
table {
display: block;
}
tbody {
display: grid;
grid-template-columns: repeat(15, 1fr);
/* is this not too much 3 x 15 = 45 columns!! */
}
tr {
display: flex;
}
tr :first-child {
font-weight: bold;
color:blue
}
td {
border: solid 1px;
flex: 1;
margin: 1px;
}
/* } */
<table>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
...
<table>
other options via grid & flex
/* media commented fo visual test */
/* #media print { */
table {
display: block;
}
tbody {
display: grid;
grid-template-rows: repeat(45, auto);
grid-auto-flow: column dense;
}
tr {
display: flex;
}
tr :first-child {
font-weight: bold;
color:blue
}
td {
border: solid 1px;
flex: 1;
margin: 1px;
}
/* } */
<table>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<table>
or
/* media commented fo visual test */
/* #media print { */
table {
display: block;
}
tbody {
display: grid;
grid-template-rows: repeat(45, auto);
grid-auto-flow: column dense;
}
tr {
display: contents;
}
td {
border: solid 1px;
margin: 1px;
}
tr :first-child {
font-weight: bold;
color:blue;
flex-shrink:1;
}
tr:nth-child(odd) td {background:lightgray;}
/* } */
<table>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<table>
example breaking the table into a grid of 3 columns of trs:
/* media commented fo visual test */
/* #media print { */
table {
display: block;
}
tbody {
display: grid;
grid-template-columns: repeat(3, auto);
}
tr {
display: flex;
}
tr :first-child {
font-weight: bold;
color:blue
}
td {
border: solid 1px;
flex: 1;
margin: 1px;
}
/* } */
<table>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<table>
tr could also be individual inline-boxes set side by side and content drawn by column or rows.
/* media commented fo visual test */
/* #media print { */
table {
display: block;
text-align:center;
}
tbody {
display:contents;
}
tr {
display: inline-flex;
flex-direction:column;
width:12%;
text-align:initial;
}
tr :first-child {
font-weight: bold;
color:blue
}
td {
border: solid 1px;
flex: 1;
margin: 1px;
}
/* } */
<table>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<table>
/* media commented fo visual test */
/* #media print { */
table {
display: block;
text-align:center;
}
tbody {
display:contents;
}
tr {
display: inline-flex;
width:30%;
text-align:initial;
}
tr :first-child {
font-weight: bold;
color:blue
}
td {
border: solid 1px;
flex: 1;
margin: 1px;
}
/* } */
<table>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<tr>
<td>2</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>3</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>4</td>
<td>AD</td>
<td>solved</td>
</tr>
<tr>
<td>5</td>
<td>AB</td>
<td>closed</td>
</tr>
<tr>
<td>6</td>
<td>AC</td>
<td>new</td>
</tr>
<tr>
<td>1</td>
<td>AA</td>
<td>solved</td>
</tr>
<table>

jQuery how to use .nextAll() in a html table

I am to create function where when input 100 in row3, row4 and row5 the rows below it will also get 100 inserted into them. I am using nextAll() to try to do this but I think it doesn't work because the rows are not together in an order. Is there some thing I am not doing right?
$("input[id^=row]").on("change", function() {
$(this).nextAll("input[id^=row]").val($(this).val());
console.log($(this).val())
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<th>Year</th>
<th>Age</th>
<th>Annual Premium<br>(Beginning of Year)</th>
<th>Benefits<br>(End of Year)</th>
<th>Time</th>
<th>Policyholder's Cashflow</th>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td id='annual0'>0</td>
<td id='benefit0'><input class='row' id='row0'></td>
<td>0</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td id='annual1'>0</td>
<td id='benefit1'><input class='row' id='row1'></td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>3</td>
<td>5</td>
<td id='annual2'>0</td>
<td id='benefit2'><input class='row' id='row2'></td>
<td>2</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>6</td>
<td id='annual3'>0</td>
<td id='benefit3'><input class='row' id='row3'></td>
<td>3</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>7</td>
<td id='annual4'>0</td>
<td id='benefit4'><input class='row' id='row4'></td>
<td>4</td>
<td></td>
</tr>
$("input[id^=row]").on("input", function() {
$(this).nextAll("input[id^=row]").val($(this).val());
console.log($(this).val())
});
<tr>
<th>Year</th>
<th>Age</th>
<th>Annual Premium<br>(Beginning of Year)</th>
<th>Benefits<br>(End of Year)</th>
<th>Time</th>
<th>Policyholder's Cashflow</th>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td id='annual0'>0</td>
<td id='benefit0'><input class='row' id='row'></td>
<td>0</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td id='annual1'>0</td>
<td id='benefit1'><input class='row' id='row1'></td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>3</td>
<td>5</td>
<td id='annual2'>0</td>
<td id='benefit2'><input class='row' id='row2'></td>
<td>2</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>6</td>
<td id='annual3'>0</td>
<td id='benefit3'><input class='row' id='row3'></td>
<td>3</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>7</td>
<td id='annual4'>0</td>
<td id='benefit4'><input class='row' id='row4'></td>
<td>4</td>
<td></td>
</tr>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
try on("input") instead of on('change'),

MYSQL group by day with Start and End Date

I have multiple reminder in the table I'm saving that reminder with date range so the reminder will display within that date like this
<table>
<tr>
<th>id</th>
<th>reminder</th>
<th>start_date</th>
<th>end_date</th>
</tr>
<tr>
<td>1</td>
<td>Call to Alex</td>
<td>2017-09-16</td>
<td>2017-09-23</td>
</tr>
<tr>
<td>2</td>
<td>Call to Crame</td>
<td>2017-09-19</td>
<td>2017-09-20</td>
</tr>
</table>
I want to get the data by day for example like below I'm getting the value by current date I don't know how to query by datte in two different columns. Kindly help me to find the solution.
<table>
<tr>
<th>date</th>
<th>reminder count</th>
</tr>
<tr>
<td>2017-09-16</td>
<td>1</td>
</tr>
<tr>
<td>2017-09-17</td>
<td>1</td>
</tr>
<tr>
<td>2017-09-18</td>
<td>1</td>
</tr>
<tr>
<td>2017-09-19</td>
<td>2</td>
</tr>
<tr>
<td>2017-09-20</td>
<td>2</td>
</tr>
<tr>
<td>2017-09-21</td>
<td>1</td>
</tr>
<tr>
<td>2017-09-22</td>
<td>1</td>
</tr>
<tr>
<td>2017-09-23</td>
<td>1</td>
</tr>
<tr>
<td>2017-09-24</td>
<td>0</td>
</tr>
</table>

How do I create an HTML table with the following structure?

I'm trying to create a table with the following structure.
I've been reading various sites and blogs to try to create this myself, but I have failed, terribly, and decided to ask for help here.
So far, I've been able to create the outer structure:
<table border='1' style="width:100%">
<tr>
<td>Foo</td>
<td>Bar</td>
</tr>
<tr>
<td>Bak</td>
<tr></tr>
<td>Baz</td>
</tr>
<tr>
<td>Foo</td>
<td>Bar</td>
</tr>
<tr>
<td>Bak</td>
<td>Baz</td>
</tr>
</table>
But I can't figure out how to add the fields for Name, Number, and Cost. How do I nest it?
Use rowspan to cause a cell to appear in multiple rows, headers to link your data cells with header cells that aren't in traditional positions, and tbody to describe subdivisions of a table.
table, td, th {
border-collapse: collapse;
border: solid black 1px;
padding: 3px;
}
<table>
<tbody>
<tr>
<td rowspan="3"> ...
<th id="name_1"> Name
<td headers="name_1"> ...
<tr>
<th id="number_1"> Number
<td headers="number_1"> ...
<tr>
<th id="cost_1"> Cost
<td headers="cost_1"> ...
<tbody>
<tr>
<td rowspan="3"> ...
<th id="name_2"> Name
<td headers="name_2"> ...
<tr>
<th id="number_2"> Number
<td headers="number_2"> ...
<tr>
<th id="cost_2"> Cost
<td headers="cost_2"> ...
</table>
You need to use rowspan JSFIDDLE
<table border="1">
<tr>
<td rowspan="3"></td>
<td>Name</td>
<td>&nbsp</td>
</tr>
<tr>
<td>Number</td>
<td> </td>
</tr>
<tr>
<td>cost</td>
<td> </td>
</tr>
<tr>
<td rowspan="3"></td>
<td>Name</td>
<td>&nbsp</td>
</tr>
<tr>
<td>Number</td>
<td> </td>
</tr>
<tr>
<td>cost</td>
<td> </td>
</tr>
</table>
try fiddle fiddle
<table border='1' style="width:100%">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td rowspan="3">some</td>
<td>Name</td>
<td>11</td>
</tr>
<tr>
<td>No</td>
<td>22</td>
</tr>
<tr>
<td>Cost</td>
<td>22</td>
</tr>
</table>
User rowspan
<table border="1">
<tr>
<td rowspan="3">Data Section 1</td>
<td>Some Data 1.1</td>
</tr>
<tr>
<td>Some Data 1.2</td>
</tr>
<tr>
<td>Some Data 1.3</td>
</tr>
<tr>
<td rowspan="3">Data Section 2</td>
<td>Some Data 2.1</td>
</tr>
<tr>
<td>Some Data 2.2</td>
</tr>
<tr>
<td>Some Data 2.3</td>
</tr>
</table>
<table border='1' style="width: 100%">
<tr>
<td rowspan="3">1</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td rowspan="3">1</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td rowspan="3">1</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
</table>
In general way like this
<table border="1">
<tr>
<td rowspan="3">1</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td rowspan="3">2</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
</tr>
<tr>
<td rowspan="3">3</td>
<td>13</td>
<td>14</td>
</tr>
<tr>
<td>15</td>
<td>16</td>
</tr>
<tr>
<td>17</td>
<td>18</td>
</tr>
</table>
http://jsfiddle.net/s5b0c5d9/

Table with 3 headers, how to have different number of row cell?

I want to achieve this table structure
a | b | c
1 | 1 | 1
2 | 2 | 2
3 | 3 | 3
| | 4
I have this code but it puts the 4 in another column instead of underneath the 3
<table border="0">
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
You will have to make some empty cells, the row with the '4' in it, is a new row:
<table border="0">
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td></td>
<td></td>
<td>4</td>
</tr>
</table>
<table border="0">
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>4</td>
</tr>
</table>
This is normal : in your table header, you defined three different headers, thus three different columns. Since <td></td> defines a column in a table, your '4' gets its own column which is not defined by the column headers of the table.
In order to let the 4 go underneath the 3, you should make a new table row with the last containing 4, like this :
<table border="0">
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td></td>
<td></td>
<td>4</td>
</tr>
</table>
As analternative to the toher answers that add a new row, if you want the 4 to be in the same table cell as the 3, just add a line break inside the table cell
...
<tr>
<td>1</td>
<td>2</td>
<td>3<br/>4</td>
</tr>
</table>
or use div tags in the cell like this
...
<tr>
<td>1</td>
<td>2</td>
<td>
<div>3</div>
<div>4</div>
</td>
</tr>
</table>