天道酬勤,学无止境

jointable

Hibernate : How to Join 3 tables in one join table by Annotation?

I have some roles, users and applications I want to create a mapping hibernate of this table : CREATE TABLE role_application_user ( role_identifier INTEGER not null, application_identifier INTEGER not null, user_identifier INTEGER not null, KEY FK_role_identifier (role_identifier), KEY FK_application_identifier(application_identifier), KEY FK_user_identifier (user_identifier), CONSTRAINT FK_role_identifier FOREIGN KEY (role_identifier) REFERENCES role (identifier), CONSTRAINT FK_application_identifier FOREIGN KEY (application_identifier) REFERENCES application (identifier), CONSTRAINT FK_user

2021-11-26 09:50:57    分类:问答    java   hibernate   many-to-many   jointable

带条件的 Laravel 连接查询(Laravel join query with conditions)

问题 我有4张桌子。 用户表: id col1 col2 课程分配表: id user_id course_id approved 课程信息表: id parent_id CourseParents表: id start_date end_date 我认为表名及其列名是不言自明的。 我有两种用户 - i)已分配 ii)未分配。 我在 2 个不同的页面中展示它们。 在显示分配的学生时,我需要来自users表的那些学生,其中每个学生在CoursesAssigned表中至少有一行,其中user_id是他自己的用户 ID, approved字段是 1 并且该行中的course_id有自己的parent_id (来自CourseInfo ) 和end_date (来自CourseParents )大于或等于今天。 为了显示未分配的学生,我需要用户表中的那些学生,对于每个人 - 任何一个 CoursesAssigned表中没有一行,其中user_id是他自己的用户 ID, approved列的值为 1。也就是说,对于未分配的用户,可能存在具有他自己的用户 ID 的行,但approved字段包含 0。 或者 CoursesAssigned表中可能有一些行, user_id是他自己的用户 ID, approved字段值为 1,但从CourseInfo获得的parent

2021-11-24 15:32:28    分类:技术分享    laravel   query-builder   jointable   laravel-query-builder

将一行加入所有行并返回所有行(join one row to all row and returning all row)

问题 我可以从我的表中获取这样的数据吗 | id_outlet| date | count(msisdn) | | 34.10.1 | 2014-08 | 0 | | 34.10.1 | 2014-09 | 3 | | 34.10.1 | 2014-10 | 2 | | 34.10.2 | 2014-08 | 1 | | 34.10.2 | 2014-09 | 0 | | 34.10.2 | 2014-10 | 0 | 所以我有2张桌子 1.表插座(独特) 2. 餐桌销售(餐桌分店详情) 正如你在我的第二张表中看到的,有 3 个周期(2014-08、2014-09、2014-10) 我想像那个例子一样在第一个表中加入带有 id_outlet 的 periode。 我可以吗? 请帮我 回答1 使用交叉连接:- SELECT o.id_outlet, s_main.periode, o.branch, count(msisdn) FROM ( SELECT DISTINCT SUBSTRING(date,1,7) AS periode FROM sales ) s_main CROSS JOIN outlet o LEFT OUTER JOIN sales s ON s_main.periode = SUBSTRING(s.date,1,7) AND o.id_outlet = s

2021-11-19 19:44:25    分类:技术分享    mysql   jointable

Laravel join query with conditions

I have 4 tables. User table: id col1 col2 CoursesAssigned table: id user_id course_id approved CourseInfo table: id parent_id CourseParents table: id start_date end_date I think the table names and its column names are self explanatory. I have 2 kinds of users - i) assigned ii) unassigned. I show them in 2 different pages. While showing the assigned students I need those students from users table for each of whom there is at least one row in CoursesAssigned table where user_id is his own user id and the approved field is 1 and the course_id in that row has its own parent_id (from CourseInfo)

2021-11-14 17:55:42    分类:问答    laravel   query-builder   jointable   laravel-query-builder

join one row to all row and returning all row

can I get data like this from my table | id_outlet| date | count(msisdn) | | 34.10.1 | 2014-08 | 0 | | 34.10.1 | 2014-09 | 3 | | 34.10.1 | 2014-10 | 2 | | 34.10.2 | 2014-08 | 1 | | 34.10.2 | 2014-09 | 0 | | 34.10.2 | 2014-10 | 0 | So I have 2 tables 1. table outlet (unique) 2. table sales (detail of table outlet) As u see in my second table there are 3 periode (2014-08, 2014-09, 2014-10) I want join that periode with id_outlet in first table like that example. Can I? Please Help me

2021-11-13 05:12:34    分类:问答    mysql   jointable

如何在创建时将数据传递给连接表(How to pass data to join table on creation)

问题 我有以下结构: class User < ActiveRecord::Base has_many :device_ownerships has_many :devices, :through => :device_ownerships end class Device < ActiveRecord::Base has_one :device_ownership has_one :user, :through => :device_ownership end class DeviceOwnership < ActiveRecord::Base belongs_to :user belongs_to :device end 但是 DeviceOwnership 也有 serial_number 行 我想在创建时将 serial_number 值传递给 DeviceOwnership。 我知道我可以做类似的事情 def create user = User.create device = Device.create device_ownership = DeviceOwnership.create(:serial_numer => params[:device_serial_number], :device_id => device.id, :user_id => user.id)

2021-11-12 07:45:16    分类:技术分享    ruby-on-rails   ruby-on-rails-4   jointable

How to pass data to join table on creation

I have the following structure: class User < ActiveRecord::Base has_many :device_ownerships has_many :devices, :through => :device_ownerships end class Device < ActiveRecord::Base has_one :device_ownership has_one :user, :through => :device_ownership end class DeviceOwnership < ActiveRecord::Base belongs_to :user belongs_to :device end However DeviceOwnership also has serial_number row I want to pass serial_number value to DeviceOwnership on create. I understand I can do something like def create user = User.create device = Device.create device_ownership = DeviceOwnership.create(:serial_numer

2021-11-11 04:39:40    分类:问答    ruby-on-rails   ruby-on-rails-4   jointable

在 CakePHP 3.0 的 add 方法中将附加数据保存到连接表(Saving Additional Data to the Join Table in the add method in CakePHP 3.0)

问题 在书中的这个例子中: https://book.cakephp.org/3.0/en/orm/associations.html#using-the-through-option class StudentsTable extends Table { public function initialize(array $config) { $this->belongsToMany('Courses', [ 'through' => 'CoursesMemberships', ]); } } class CoursesTable extends Table { public function initialize(array $config) { $this->belongsToMany('Students', [ 'through' => 'CoursesMemberships', ]); } } class CoursesMembershipsTable extends Table { public function initialize(array $config) { $this->belongsTo('Students'); $this->belongsTo('Courses'); } } 我想在添加新student时输入与课程 #8 相对应的grade 。

2021-11-10 22:11:40    分类:技术分享    php   mysql   cakephp-3.0   jointable

cakePHP 表连接两个表问题(cakePHP table joining two tables issue)

问题 我是 cakePHP 的新手,整个表关系的概念很混乱! 我有 2 个表,能力和能力评级。 能力存储带有 id 的名称列表。 competencies ------------ id name 并且用户可以从该表中选择各种能力并对它们进行评级,他们的评级存储在competenceRatings 表中。 competenceRatings ----------------- id competence_id user_id rating 我希望能够将用户尚未对其进行任何评级的能力的名称放入到能力评级表中。 即,我需要能力表中的名称列表,其中在 comptenceRatings 表中没有条目(对于给定的 user_id)。 我尝试了能力->hasMany->competenceRatings、competenceRatings->belongsTo->能力关系。 $competencies = $this->Competence->CompetenceRating->find('all',array('CompetenceRating.user_id' => $userId,'CompetenceRating.competence_id !=' => 'Competence.id')); 但是没有用! 这个结果是否需要任何其他关系? 或者我可以在查找查询中使用连接条件连接表吗?

2021-11-09 11:34:30    分类:技术分享    cakephp   jointable

cakePHP table joining two tables issue

Im new to cakePHP and the whole table relations concept is very confusing! I have 2 tables, competencies and competenceRatings. competencies stores a list of names with ids. competencies ------------ id name And users can select various competencies from this table and rate them and their ratings are stored into competenceRatings table. competenceRatings ----------------- id competence_id user_id rating I want to be able to get the names of competencies for which a user have NOT made any ratings into competenceRatings table. i.e., I need list of names from competencies table for which there

2021-11-08 02:56:40    分类:问答    cakephp   jointable