如何更改此视图,以便它可以在MS中使用
CREATE OR REPLACE VIEW users_with_meta_view AS
SELECT
u.id,
u.user_login AS login,
u.user_pass AS password,
u.user_email AS email,
(select meta_value from wp_usermeta where user_id = u.id and meta_key
= 'first_name' limit 1) as first_name,
(select meta_value from wp_usermeta where user_id = u.id and meta_key
= 'last_name' limit 1) as last_name,
(select meta_value from wp_usermeta where user_id = u.id and meta_key
= 'country' limit 1) as country
FROM wp_users u
答案 0 :(得分:0)
可能是:
SELECT
u.id,
u.user_login AS login,
u.user_pass AS [password],
u.user_email AS email,
(select first(meta_value) from wp_usermeta where user_id = u.id and meta_key = 'first_name') As first_name,
(select first(meta_value) from wp_usermeta where user_id = u.id and meta_key = 'last_name') As last_name,
(select first(meta_value) from wp_usermeta where user_id = u.id and meta_key = 'country') As country
FROM
wp_users As u
如果备忘录出现问题,请尝试:
(select first(Left(meta_value, 255)) from wp_usermeta where user_id = u.id and meta_key = 'first_name') As first_name,
或:
(select top 1 meta_value from wp_usermeta where user_id = u.id and meta_key = 'first_name') As first_name,