balderdashy / balderdashy/sails
How to use 'INNER JOIN'
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Node version**:
14
**Sails version** _(sails)_:
1.4.3
**ORM hook version** _(sails-hook-orm)_:
"sails-mysql": "^1.0.1",
I have two table.
event
```sql
CREATE TABLE `event` (
`id` int NOT NULL AUTO_INCREMENT,
`title` text COLLATE utf8mb4_bin,
`organization` int NOT NULL,
`createdAt` datetime DEFAULT NULL,
`updatedAt` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
```
organization
```sql
CREATE TABLE `organization` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`region` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
```
The `organization` field of the Event table is the ID of the table organization, one organization corresponds to multiple events。
now, I want to implement the following SQL query, What should I do?and How should I count the number of query records?
```sql
select e.title, e.organization, o.region from event e inner join organization o on e.organization= o.id where o.region='xx';
```
Contributor guide
Research direction
Start with the Sails 1.4.3 ORM documentation and the sails-mysql adapter details mentioned in the issue, using the provided event and organization schemas and SQL query as the example. Determine how an INNER JOIN and a record count are supported, then document a clear usage path or identify what is missing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql, node.js
- Domain
- backend, database
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100