I have data like this:
<table>
<tr>
<th>Item_Code</th>
<th>Size</th>
<th>Count</th>
</tr>
<tr>
<td>1001</td>
<td>XL</td>
<td>10</td>
</tr>
<tr>
<td>1001</td>
<td>XXL</td>
<td>5</td>
</tr>
<tr>
<td>1002</td>
<td>3XL</td>
<td>3</td>
</tr>
<tr>
<td>1002</td>
<td>XL</td>
<td>10</td>
</tr>
</table
I want result as below
<table>
<tr>
<th>Item_Code</th>
<th>Size</th>
<th>Count</th>
</tr>
<tr>
<td>1001</td>
<td>XL,XXL</td>
<td>15</td>
</tr>
<tr>
<td>1002</td>
<td>3XL,XL</td>
<td>13</td>
</tr>
</table>
I want this thing in SQL Server. Can anyone please help me with this?
I know the query to concatenate the multiple row values into a single column, but I don't know along with other columns also.
Related
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>
I am working on a project using Symfony2.8 and MySQL.
I have 4 tables in my database that are users, quotes, articles, articlesquotes.
user table
<html>
<body>
<table border="1">
<tr>
<th>user_id</th>
<th>name</th>
<th>age</th>
</tr>
<tr>
<td>7</td>
<td>Alex</td>
<td>20</td>
</tr>
<tr>
<td>8</td>
<td>John</td>
<td>30</td>
</tr>
</table>
</body>
</html>
quotes table
<html>
<body>
<table border="1">
<tr>
<th>quote_id</th>
<th>user_id</th>
<th>reference</th>
</tr>
<tr>
<td>61</td>
<td>7</td>
<td>AE20</td>
</tr>
<tr>
<td>62</td>
<td>7</td>
<td>AE21</td>
</tr>
<tr>
<td>63</td>
<td>7</td>
<td>AE22</td>
</tr>
<tr>
<td>64</td>
<td>8</td>
<td>AE29</td>
</tr>
</table>
</body>
</html>
articlesquote
<html>
<body>
<table border="1">
<tr>
<th>id</th>
<th>quote_id</th>
<th>article_id</th>
<th>qte</th>
</tr>
<tr>
<td>58</td>
<td>61</td>
<td>2</td>
<td>7</td>
</tr>
<tr>
<td>59</td>
<td>62</td>
<td>3</td>
<td>8</td>
</tr>
<tr>
<td>60</td>
<td>63</td>
<td>1</td>
<td>9</td>
</tr>
<tr>
<td>61</td>
<td>63</td>
<td>2</td>
<td>10</td>
</tr>
</table>
</body>
</html>
articles table
<html>
<body>
<table border="1">
<tr>
<th>article_id</th>
<th>name</th>
</tr>
<tr>
<td>1</td>
<td>article1</td>
</tr>
<tr>
<td>2</td>
<td>article2</td>
</tr>
<tr>
<td>3</td>
<td>article3</td>
</tr>
</table>
</body>
</html>
now the relation between these tables is
user<--One-To-Many-->quote<--one-To-Many-->ArticlesQuote<--Many-To-One-->Article
I would like to get articles that are in all quotes of user number 7 ordered by quote_id
I would like to get articles that are in quote number 63 of the user number 7
thank you for helping me.
try this:
Select a.* From articles a
Inner Join
articlesquote aq On a.article_id=aq.article_id
Inner Join
quotes q On q.quote_id=aq.quote_id
Inner Join
user u On u.user_id=q.user_id
Where
u.user_id=7 and q.quote_id=63
I have to arrange table cells as shown in the image below, I am using bootstrap, and I have adjusted it using colspan. but it not works as like in the image.
I have fiddeled here
<table class="table table-bordered table-responsive">
<thead></thead>
<tfoot></tfoot>
<tbody>
<tr>
<td rowspan="4">a</td>
<td rowspan="2" colspan="2">aaa</td>
</tr>
<tr>
<td>asas</td>
<td>asas</td>
</tr>
<tr>
<td>asas</td>
<td>asas</td>
</tr>
<tr>
<td>asas</td>
<td>asas</td>
</tr>
</tbody>
How can I get the table as shown in the image.
I use this to generate the table:
<table border="1" width="500">
<tr>
<td rowspan="3">1</td>
<td colspan="2">2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td rowspan="4">7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>10</td>
<td>11</td>
</tr>
<tr>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td>14</td>
<td>15</td>
</tr>
</table>
I've searched online and I can't find an answer, so I'm going to ask this question.
The new data will always be formatted in the following and will be populated in id="content"
<tr>
<td>name</td>
<td>age</td>
<td>gender</td>
</tr>
I read you need to have <div> inside a <td> if you're going to put <div> inside a <table>. Right now, the format is not correct. All of the new data are in column one instead of each of them in each row.
<table>
<tr>
<th>name</th>
<th>age</th>
<th>gender</th>
</tr>
<td>
<div id="contents">
<tr>
<td>John</td>
<td>12</td>
<td>male</td>
</tr>
<tr>
<td>Jess</td>
<td>13</td>
<td>female</td>
</tr>
</div>
<td>
</table>
Update
re-reading your structure you most likely need
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
<th>gender</th>
</tr>
</thead>
<tbody id="contents">
<tr>
<td>John</td>
<td>12</td>
<td>male</td>
</tr>
<tr>
<td>Jess</td>
<td>13</td>
<td>female</td>
</tr>
</tbody>
</table>
Original answer
You can't have tr as direct children of a div.
You need to use a table
Either
<table>
<tr>
<th>name</th>
<th>age</th>
<th>gender</th>
</tr>
<td>
<table id="contents">
<tr>
<td>John</td>
<td>12</td>
<td>male</td>
</tr>
<tr>
<td>Jess</td>
<td>13</td>
<td>female</td>
</tr>
</table>
<td>
</table>
or
<table>
<tr>
<th>name</th>
<th>age</th>
<th>gender</th>
</tr>
<td>
<div id="contents">
<table>
<tr>
<td>John</td>
<td>12</td>
<td>male</td>
</tr>
<tr>
<td>Jess</td>
<td>13</td>
<td>female</td>
</tr>
</table>
</div>
<td>
</table>
I think that you want the table to be inside the div completely, and all the new data be in a corresponding row, like this:
<div id="contents">
<table>
<tr>
<th>name</th>
<th>age</th>
<th>gender</th>
</tr>
<tr>
<td>John</td>
<td>12</td>
<td>male</td>
</tr>
<tr>
<td>Jess</td>
<td>13</td>
<td>female</td>
</tr>
</table>
</div>
Right now the format is wrong because of you are trying to add whole data into a single cell (<td> element) which isn't right way to do.
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> </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> </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/