Sql简单的初学者操作 [英] Sql simple beginner operation

查看:65
本文介绍了Sql简单的初学者操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 USERS 的表,以 user_id 为主键, user_name



我有另一个表 USERS_ACT user_act_id 主键, user_act_user_id 和另外2列。



我需要 user_act_user_id 作为中的外键 ?如何实现这个?



这是我在SQL的第一天,所以请大家解释一下我问的是不是。


<假设您不是数据库管理员,而只想获取所有活动用户的名称;))


$ b $

b

  select users.user_name 
from users
join users_act on users.user_id = users_act.user_act_user_id
pre>

I have a table named USERS with user_id as primary key and user_name.

I have another table USERS_ACT with user_act_id primary key, user_act_user_id and another 2 columns.

I need user_act_user_id to be foreign key in USERS? How can I achieve this?

This is my first day in SQL so please be kind to explain if what I ask is wrong.

解决方案

let's assume you are not the DB admin and you just want to get all the active users' names ;))

select users.user_name
from users
join users_act on users.user_id = users_act.user_act_user_id

这篇关于Sql简单的初学者操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆