I assume you’re already properly using the WP Metadata API https://codex.wordpress.org/Metadata_API to attach the field to new comments and you just want to backfill for existing comments by stuffing the database?
If it was my problem, I wouldn’t bother and would assume in my code that absence of meta implied no likes. If you use update_meta_data() to update the values when users like a comment, then it will create the meta key,value pair if it doesn’t exist.
But, to answer your actual question, you don’t want the ASs. This works for me:
INSERT INTO wp_commentmeta( comment_id, meta_key, meta_value ) SELECT comment_ID, 'likes', 0 FROM wp_comments WHERE comment_approved = '1';
Related Posts:
- What SQL Query to do a simple find and replace
- Adding another state (spam, reject, approve) to wordpress comments?
- How to remove Profile Picture section or the message “You can change your profile picture on Gravatar.”
- Add field to posts (checkbox) that only one post can have
- generate unique number when registering a user
- Custom Fields Bulk Edit
- How to get value from custom backend menu
- Allow Users to Set Password During Registration
- How can I manage my multiple wordpress websites from main website?
- Custom protected password page with ACF
- How to find if a post with custom_field == X exists?
- Passing page url into a custom field via the Press-This bookmarklet
- How to extend nav-menu-item-control data in Appearance > Customize?
- Custom column sorting in WordPress admin post table
- show the meta values to visitors that collected via coment form
- Hide custom field if empty
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- list/consult Taxonomy only for the respective author/creator in dashbboard
- Advanced Custom Fields: Sorting custom columns with custom fields sorts only by date
- How to change popular term checklist title when edit post?
- Add a date updated/date modified option using custom fields
- How to add textarea field to taxonomy (tag)?
- How to add an extra button on woocommerce shop page and use it to send the product info with image in a mail? [closed]
- Woocomerce custom billing address fields display in order details [closed]
- The function can not create a table on MariaDB server
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- wpdb custom tables without plugin
- What requirements for ACF custom fields key and name properties?
- My custom sql query for getting a username giving me a warning and an error
- How to insert a writing panel between the title and the page content?
- Toggle custom fields?
- dbDelta not creating tables with composite keys
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- Applying WP-cli Search & Replace to Static SQL Dump File
- How to print Array values of custom Fields Meta?
- Get users based on month ACF datepicker field
- What is the best way to modify Admin Panel on WordPress?
- how to make a custom field readonly or disabled by user role?
- theme customizer – can a single option pass multiple values?
- Let author add field to metabox by pressing a button
- How to auto add nofollow to links in custom field?
- Troubles about insering a POST with a SQL query, post_status
- query_posts meta_key with current date
- saving the widgets position after drag and drop
- Is it possible to add custom badges to product attributes conditionally, based on custom field?
- How to get Previous Visited Page Information
- export and import wordpress customization
- WordPress category custom title
- No plugin populate user information in to form
- How can Use custom input field in functions.php page?
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Simple custom attributes on posts
- Use a custom page with dynamic content as a user profile page
- WP Query – grouping posts by same meta key, adding together values from another key
- What is my error trying to create a new table in the database?
- Query Product categories what have a custom field
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- Replace publish date in blog module with custom field
- How do I enable the text editer in my WordPress theme? [closed]
- How to add H1 Tag on Homepage?
- Does WordPress support template resources/custom fields
- Change post template the proper way
- Pre_Get_Posts order DESC not registering
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
- Has the table name in SQL for WordPress changed from WP_posts to WPCS_post?
- Add custom information in editor summary
- How to *remove* a parent theme page template from a child theme?
- How to disable page delete
- Search multiple custom fields by using meta_query
- How to update the delete user confirmation form?
- wpdb->prepare function remove single quote for %s in SQL statment
- In the new Theme Customizer API, how to send a value from the front back to the admin panel?
- sanitize attachment filename
- How do I add a new template to my site
- How can I use a Tiny MCE editor in my custom Gutenberg block?
- How to customize and keep things up-to-date?
- What happens to the mu-plugins folder when you upgrade to WordPress 3?
- How to make wordpress use a non-wordpress users table?
- Allow multisite admins only to create users with one specific user role?
- Make tag archive display post are ordered by post format
- How to Clear Empty Search values?
- Find locations of all featured images of draft posts via SQL
- How to get WordPress Theme Customizer options in the REST API?
- Creating a WP Test site without /uploads etc
- How to define active widget with js in a customizer
- where can i find the login page in wordpress and add my header to it
- How to change link in all posts?
- Include a custom field in mysql query
- ‘str_replace’ and ‘strtr’ not working inside plugin
- SAving PHP in custom wordpress option field
- Edit a custom admin page
- Show or hide lang=”ur” in main element
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- Cannot upload to S3 using CDN Sync Tool
- Custom Import with taxonomies
- Very Simple Geo targeting
- Consolidate ‘add-to-cart’ buttons into one ‘add-all-to-cart’ button
- Update to WordPress 4.9.2, but have heavily customized theme