这个很简单啊,就是从地理信息表中随机取个记录,全关联到用户表上就行。
select 姓氏,名字,t2.id,t2.城市 from sales_雇员
/*原表与随机取到的地址关联*/
full join
(
select * from (
select 1 as id,'北京' as 城市
union
select 2 as id,'上海' as 城市
union
select 3 as id,'广州' as 城市
) t0
where id=
(
/*随机获取个城市*/
select round(RAND()*(SELECT MAX(id) as 随机获取的ID FROM (
select 1 as id,'北京' as 城市
union
select 2 as id,'上海' as 城市
union
select 3 as id,'广州' as 城市
)
t1
)
)
)
)
t2
例如:
原表:只有姓氏和名字。
模拟一个城市表:
随机取城市ID:
在关联城市完成信息:
最后一full join就ok了。