php


MySQL: How do I join the same table multiple times?


I have three tables that are used within my query: users, posts and swaps.
Here's the structure of the tables.
Swaps:
https://i.imgur.com/OdmsdGt.png
Posts:
https://i.imgur.com/gzIz1FX.png
This is my current query that partially works:
"SELECT item_name, item_thumb, item_id, swap_item, swap_message, username
FROM users
JOIN swaps ON swaps.sender_id = users.id
JOIN posts ON posts.item_id = swaps.product_id
WHERE seller_id = {$_SESSION['id']}"
Now the issue is that I've already joined the item_id from the posts table to the product_id in the swaps table.
I'd also like the join the column swap_item from the swaps table to the item_id within the posts table... If that makes sense?
I've tried using aliases to my best understanding but haven't had any luck.

Related Links

Create managed stripe account with php and swift
Notice: Trying to get property of non-object in C:\xampp\htdocs\API\apiukms\example.php on line 66 [duplicate]
Get Data From SQL Server With PHP (Interest Object)
How to search through directory for a string
optimizing memory resources for a big query response
Inserting an image name and number into database
FPDF Table Results from Array
I have a PHP multi dimensional associative array I want to convert into JSON that has an array and an object inside
Function variable not showing up in xDebug with Symfony 3
How to assign variables in twig?
When putting rows into array it duplicates
PHP mysql adding to table from form [duplicate]
htaccess re-write for restful api
Call to undefined function Zend\Mail\Header\iconv_mime_decode()
How to read 5 lines from text file then save the remaining lines back to this same file
get value of http request headers in php

Categories

HOME
events
user-interface
plesk
class
gaming
qc
mousemove
mosquitto
openfoam
haxe
graphql-js
spring-security-oauth2
heuristics
xades4j
erd
fullcalendar-scheduler
spring-jpa
sonicwall
batch-rename
rxjs5
device
channel
nurbs
onchange
sfml
microprocessors
mdns
openbr
locks
phpstorm-2016.1
char-pointer
sspi
task-parallel-library
python-jira
plane
react-intl
intellij-lombok-plugin
sonarqube5.2
libreoffice-writer
md5-file
sonicmq
extjs4.1
sequence-diagram
gtk#
google-news
portability
email-forwarding
gmaps.js
wildfly-9
oid
multi-touch
bilinear-interpolation
dmarc
jenkins-workflow
bbc-micro
static-methods
yii2-model
adp
processor
gwt-syncproxy
grinder
perceptron
juniper-network-connect
ibm-was
dsa
dnx50
extend
artisan
unidata
erlog
shoes
mgwt
kognitio-wx2
createfile
flurry-analytics
otl
commenting
mute
ax
delphi-xe4
aero
simplecov
system-requirements
chronometer
opends
background-repeat
delphi-prism
uipasteboard
canonicalization
tablet-pc
aggregator
j2mepolish
mysqli-multi-query
sqlsitemapprovider
rakudo
remote-working
error-detection

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App