I gang

MySql Query Alteration

I have a query containing 2 JOINS and a COUNT() which I am needing altered to allow an OR statement across the field value of 2 tables.

Heres the tables:

I have 3 tables as follows:

+-----------+--------------+

table1> categories

+-----------+--------------+

| CatID | category

+-----------+--------------+

| 1 | category1 |

| 2 | category2 |

| 3 | category3 |

| 4 | category4 |

etc..

+-----------+--------------+

+-----------+--------------+--------------+

table2> cat_type_link

+-----------+--------------+--------------+

| linkID | Link_CatID | CatType

+-----------+--------------+--------------+

| 1 | 1 | 1

| 2 | 1 | 2

| 3 | 2 | 1

| 4 | 3 | 2

| 4 | 4 | 1

etc..

+-----------+--------------+--------------+

+-----------+--------------+--------------+

table3> posts

+-----------+--------------+--------------+

| postID | Post_CatID | status

+-----------+--------------+--------------+

| 1 | 1 | 0

| 2 | 2 | 1

| 3 | 2 | 1

| 4 | 1 | 1

| 3 | 3 | 1

| 4 | 1 | 1

etc..

+-----------+--------------+--------------+

And I am currently using the below query to produce the following result:

Result:

category1 (# of posts 2)

category2 (# of posts 2)

category4 (# of posts 0)

The current query:

SELECT [url removed, login to view], [url removed, login to view], [url removed, login to view] , COUNT([url removed, login to view]) postcount

FROM categories a

INNER JOIN cat_type b ON [url removed, login to view] = [url removed, login to view] AND [url removed, login to view] = 2

LEFT OUTER JOIN posts c ON [url removed, login to view] = c.Post_CatId AND [url removed, login to view] = 1

GROUP BY [url removed, login to view], [url removed, login to view], [url removed, login to view]

ORDER BY postcount

What I am needing for this job is to recreate the above query to allow count() result where [url removed, login to view] = 2 OR [url removed, login to view] = 1

Færdigheder: MySQL

Se mere: n query, linkid, alteration mysql, mysql query, mysql select statement, mysql containing, joins, mysql status, mysql join, order mysql, mysql statement, order status mysql, mysql field, mysql alteration, mysql statement order, count mysql, mysql left, recreate mysql, mysql select, select mysql statement, mysql category, query mysql, mysql count, query posts, using asterisk query mysql

Om arbejdsgiveren:
( 37 bedømmelser ) Abu Dhabi, United Arab Emirates

Projekt-ID: #961519

Tildelt til:

HDDevelopment

i can do it but i need another table details

$30 USD in 0 dage
(1 bedømmelse)
1.0

2 freelancere byder i gennemsnit $30 for dette job

dungvit85

ready to start this work. expert in mysql query structure.

$30 USD på 1 dag
(17 bedømmelser)
4.4